In short
A chapter from a scholarly book about the history of printing type. It shows how to build two lists at the back, one of people and one of topics, with the page where each appears.
What you'll build
Chapter four of Letters of Metal, a scholarly monograph on printing types set at 155 × 235 mm: one column of Crimson Pro, Bodoni italic for the titles, a brick-red accent. The essay runs from Gutenberg's textura through Jenson, Aldus and Griffo, Garamond and Plantin, Caslon and Baskerville, Fournier's points and the Spanish types that Pradell and Gil cut and Ibarra printed, to Bodoni's moderns. It ends as such books do, with two indexes on facing pages: the printers, punchcutters and patrons on the verso, the types, tools and books on the recto. Both come from the same marked text, and every page number in them is the page where the mark landed.
This recipe answers
- How do I print two indexes, one of names and one of subjects, from the same marked text?
- How do I build a back-of-book index whose page numbers change by themselves when the text moves?
The short answer
// Marks in the Markdown. A person goes to the names index, inverted:
// :index[Aldus Manutius]{term="Manutius, Aldus" index="names" main}
// A subject goes to the main index, with levels split by "!" and a sort key when the
// printed form would file in the wrong place:
// :index[textura]{term="Blackletter!textura" main}
// :index{term="42-line Bible" sort="Forty-two-line Bible"}
// :index{term="Cursive" see="Italic"}
// Printed at the end, each under its own heading:
// # Index of Names {style="index"} then :::index{index="names"}
// # Index of Subjects {style="index"} then :::index
const indexHeading = {
id: 'index',
numbered: false, // no chapter number, and the next chapter is still chapter 5
breakBefore: { enabled: true, parity: 'any' },
layout: { layoutType: 'double', gutterWidth: mm(7) }, // the section after the heading
};
const index = {
fontSize: pt(8.6), lineHeight: pt(11.2), // one leading for entries and letter heads
indent: em(1), turnoverIndent: em(2),
rangeFormat: 'chicago', // 212–14, as a monograph prints it
main: { bold: true }, // the page of the principal discussion
groups: { fontFamily: 'Bodoni Moda', fontSize: pt(11), fontWeight: 600, color: col('brick') },
};
Two indexes from one text, each under a two-column heading style
Ingredients
- Features
- Back-of-book indexHeading stylesUnnumbered chaptersDesigned openersHeading attributesRunning heads and foliosMirrored marginsHeads by page roleParagraph stylesSemantic colour palettePaper colourWidows, orphans and runtsPDF export
- Type
- Crimson Pro, Bodoni Moda, Libre Franklin (SIL OFL 1.1)
- Assets
- None: every picture is drawn in code
Method
#1 · Mark each person for the names index, and each subject for the main one
The code is the short answer above; the rest is in the Markdown. A mark with index="names" goes to the index that :::index{index="names"} prints, and every other mark goes to the main index that a bare :::index prints. So :index[Aldus Manutius]{term="Manutius, Aldus" index="names" main} prints the name in the text and files a bold page under Manutius in the names index, while :index[italic]{term="Italic" main} two lines further on files the same page under Italic in the subjects. A person who is a subject of the chapter can carry both marks.
#2 · Invert the names, and sort by the letters the reader will look under
Names are filed surname first: term="Garamond, Claude", term="Dall’Aglio, Margherita". The comma is part of the term, so the collator sorts Didot, Firmin before Didot, François-Ambroise as an indexer would. When the printed form would file under the wrong letter, sort gives the key: the English edition marks term="42-line Bible" sort="Forty-two-line Bible", so the Bible stands under F instead of opening a 0–9 group. Sub-entries (term="Foundries!Plantin-Moretus"), bold principal pages (main), range="start" and range="end" around the Bodoni section, and cross-references (see="Italic", seealso="Matrices") do the rest; a see target with levels prints with a colon, as in Humanist type. See Roman type: Venetian.
#3 · Build once; the document settles its own numbers
// A pass finds the page of every mark and prints both indexes with those numbers. When the
// printed index moves a mark (an index set before the text would), the layout runs again,
// until no page number changes (in a buildBundle book, the chapter with :::index gets them all).
const doc = await buildDocumentWithFonts({ markdown }, config(), kitFonts(FONTS));
The index prints page numbers that only exist after layout, and printing it takes pages of its own. buildDocument() handles that: it lays the chapter out, reads the page of every mark, prints both indexes and lays out again whenever a number changed. Here the indexes follow the text, so a second pass confirms the first; an index set before the text would shift every page after it, and the passes would go on until they agree. Add a paragraph to the Bodoni section and the index of names gives Whittingham his new page by itself.
#4 · Give each index an opener over two columns
const opener = (sink, size) => ({
enabled: true,
minHeight: pt(LEAD * sink), // the text starts on the same grid line in every chapter
slot: { elements: [
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...label, fontSize: pt(7.8),
letterSpacing: pt(1.6), color: col('brick'), align: 'left',
placement: at('container', 'top-left', 0, 10) },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Bodoni Moda', italic: true,
fontSize: pt(size), lineHeight: 1.08, color: col('ink'), align: 'left',
overflow: 'wrap', // design text ends in an ellipsis by default
placement: { ...at('#kicker', 'below', 0, 3), size: { width: 'fill', height: 'auto' } } },
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.75), color: col('brick'),
placement: { ...at('#title', 'below', 0, 4.5), size: { width: mm(16) } } },
] },
});
The heading style in the short answer does three things for # Index of Names {style="index"}: it opens a page (parity: 'any', so the two indexes follow each other without a blank), it sets the section after it in two columns 7 mm apart, and with numbered: false it leaves the chapter count alone. The style reuses the chapter opener with a six-line sink and a 20 pt title, and the letter heads repeat its Bodoni in the accent, one index line high so the columns keep their pitch.
#5 · Name the index on the recto
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, pages: 'body', // never on openers
...label, fontSize: pt(7.2), letterSpacing: pt(1.3), color: col('muted'),
placement: at('page', edge, x, 12.5), ...extra,
});
const folio = { color: col('brick'), fontWeight: 700 };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', MARGIN.outer,
{ ...folio, align: 'left' }),
head('verso-title', '{title}', 'even', 'top-left', MARGIN.outer + 8, { align: 'left' }),
head('recto-title', '{chapterTitle}', 'odd', 'top-right', -(MARGIN.outer + 8),
{ align: 'right' }),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -MARGIN.outer,
{ ...folio, align: 'right' }),
] };
// Openers carry a drop folio instead, centred under the text block.
const footer = { elements: [{ ...head('drop-folio', '{pageNumber}', 'all', 'bottom', 0,
{ ...folio, align: 'center', placement: at('page', 'bottom', 0, -12) }), pages: 'opener' }] };
The recto head prints {chapterTitle}, and an index heading is a level-one heading like any chapter, so the pages after it read Index of Subjects at the top. pages: 'body' keeps the heads off both index openers, which carry a drop folio instead.
The whole recipe
// ═══ Postext Cookbook · Nº 073 · An index of names and an index of subjects ═══════
// https://postext.dev/en/cookbook/names-and-subjects-indexes
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Crimson Pro, Bodoni Moda, Libre Franklin (SIL OFL 1.1) · Needs postext ≥ 1.28.0
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'names-and-subjects-indexes';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a warm black, one brick red for kickers, letter heads and folios
const palette = {
ink: '#211d19', // text: a warm near-black
brick: '#8e3b24', // the one accent
muted: '#6d645a', // running heads, colophon
rule: '#c8bba9', // hairlines
paper: '#fcfaf5',
};
// A colour is its hex and the palette entry it follows.
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 accent, never the default blue.
{ id: 'main-color', name: 'accent (defaults)', value: { hex: palette.brick, model: 'hex' } },
];
// #endregion
const TRIM = { width: 155, height: 235 }; // a scholarly monograph
const MARGIN = { top: 22, bottom: 24, inner: 19, outer: 22 }; // mirrored: 114 mm measure
const LEAD = 13.6; // body leading in pt
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const label = { fontFamily: 'Libre Franklin', fontWeight: 600, textTransform: 'uppercase' };
// #region answer: two indexes from one text, each under a two-column heading style
// Marks in the Markdown. A person goes to the names index, inverted:
// :index[Aldus Manutius]{term="Manutius, Aldus" index="names" main}
// A subject goes to the main index, with levels split by "!" and a sort key when the
// printed form would file in the wrong place:
// :index[textura]{term="Blackletter!textura" main}
// :index{term="42-line Bible" sort="Forty-two-line Bible"}
// :index{term="Cursive" see="Italic"}
// Printed at the end, each under its own heading:
// # Index of Names {style="index"} then :::index{index="names"}
// # Index of Subjects {style="index"} then :::index
const indexHeading = {
id: 'index',
numbered: false, // no chapter number, and the next chapter is still chapter 5
breakBefore: { enabled: true, parity: 'any' },
The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)
Variations
#Print one combined index
Drop index="names" from the marks of people and the second heading: every mark then lands in the main index, names and subjects in one alphabet.
-:index[Aldus Manutius]{term="Manutius, Aldus" index="names" main}
+:index[Aldus Manutius]{term="Manutius, Aldus" main}#Drop the letter heads
A names index this short reads well without them. groups.enabled: false removes the heads and keeps one line of space between letters; the setting applies to both indexes.
- groups: { fontFamily: 'Bodoni Moda', fontSize: pt(11), fontWeight: 600, color: col('brick') },
+ groups: { enabled: false },Pitfalls
- The
indexconfiguration is shared: both indexes take the same face, leading and letter heads. - A mark in a caption or a table cell prints as written. Mark the person in the paragraph that cites the figure.
Credits
- Recipe
- Ignacio Ferro
- Text
- “From Textura to Bodoni”, an essay on the history of printing types written for this recipe, in English and Spanish · Ignacio Ferro · CC BY 4.0
- Fonts
- Crimson Pro (SIL OFL 1.1) · Bodoni Moda (SIL OFL 1.1) · Libre Franklin (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


