In short
A small book of three letters between the King of Prussia and Voltaire. It shows how to set the date, greeting and signature of each letter, with the letters running on without new pages.
What you'll build
Five pages of Mon sort est changé, a 14 × 21 cm edition of three letters in French: the two that Frederick II wrote to Voltaire six and twelve days after he became king of Prussia, in June 1740, and Voltaire’s letter of 1 April 1778, two months before his death. On the cover, a photograph of two folded letters and a red wax seal, generated with diffusion models, lies on green morocco drawn in code inside a gilt double fillet. Inside, the letters run on with no page breaks. Each head gives the number in red small capitals and the two correspondents in Fell italic, with the place and date flush right beneath them. The salutation has a line of its own, and the signature, in small capitals, ends the letter at the right margin; Frederick’s postscript follows his signature a size smaller. The running head on each recto gives the date of the letter.
This recipe answers
- How do I set an epigraph, a dedication, a signature, or a pull quote with a big quote mark?
- How do I get good justification and hyphenation for Spanish, French or German text?
- How do I set running heads: book title on the left page, chapter title on the right, page number outside?
The short answer
// Each letter is a level-1 heading that carries its place and date as attributes:
// # Frédéric à Voltaire {place="À Charlottembourg" date="6 juin 1740"}
// (a value holds no { or }, and one with " goes in single quotes: gotcha attr-values)
const letterHead = { enabled: true, slot: { elements: [
// {number} prints the count as numberingTemplate '{1:I}' writes it.
{ kind: 'text', id: 'number', content: 'Lettre {number}', ...sc, fontSize: pt(9),
letterSpacing: pt(1.8), color: col('seal'), placement: at('container', 'top-left') },
{ kind: 'text', id: 'title', content: '{titleText}', ...fell, fontSize: pt(15),
color: col('ink'),
placement: at('#number', 'below', 0, 1) },
// The dateline spans the measure under the title and sets its words flush right;
// inlineMarks reads the attribute's marks, so date="1^er^ avril 1778" raises its ordinal.
{ kind: 'text', id: 'dateline', content: '{attr.place}, le {attr.date}.', ...crimson,
italic: true, fontSize: pt(10.4), color: col('ink'), align: 'right', inlineMarks: true,
placement: { ...at('#title', 'below', 0, 1.5), size: { width: 'fill' } } },
] } };
// The salutation, the signature and the postscript, each a :::paragraphs{style="…"} container:
// :::paragraphs{style="signature"}
// Fédéric.
// :::
const letterParts = [
{ id: 'vedette', firstLineIndent: pt(0) }, // 'Sire,' on a line of its own, flush left
{ id: 'signature', ...sc, fontSize: pt(10.5), textAlign: 'right', marginTop: pt(LEAD / 2) },
{ id: 'postscript', fontSize: pt(9), lineHeight: pt(12.6), marginTop: pt(LEAD / 2) },
];
// Hooked up below: letterHead designs the level-1 heading, letterParts joins paragraphStyles.
A letter head read from the heading, and styles for the letter's parts
Ingredients
- Features
- Heading attributesAnchoring design elementsParagraph stylesDesigned openersNumbered headingsChapters that open on a rectoHeading stylesCovers, title pages and colophonsPictures in page designsLine breaks in titlesRunning heads and foliosVerse line by lineMirrored marginsPaper colourHyphenation and document languageSuperscripts and subscriptsDocument metadataSemantic colour palettePages on a canvas
- Type
- Crimson Pro, IM Fell French Canon, IM Fell DW Pica SC (SIL OFL 1.1)
- Assets
letters-1160.jpg- The cover: two folded letters and a wax seal, a photograph (Generated With Diffusion Models, original)
- The cover’s green morocco and gilt fillet, drawn in code (Ignacio Ferro, CC BY 4.0)
Method
#1 · Read the dateline from the heading
The code is the short answer above. Each letter is a level-1 heading whose attributes hold its place and date, and the head prints them as {attr.place}, le {attr.date}. (heading attributes). The dateline’s box reaches the right edge of the column (width: 'fill'), and align: 'right' sets the words against that edge; without it, design text is centred. The salutation, the signature and the postscript are paragraph styles applied with :::paragraphs{style="…"}. The signature takes IM Fell DW Pica SC, a family whose lower case is cut as small capitals. inlineMarks: true makes the dateline read the marks in its attribute, so date="1^er^ avril 1778" raises the ordinal.
#2 · Run the letters on
const letters = { level: 1, numberingTemplate: '{1:I}', advancedDesign: letterHead,
// No break: left at the level's default, each letter would open on a recto.
breakBefore: { enabled: false }, marginTop: pt(2 * LEAD),
// The hidden heading line is measured in the heading face: italic keeps it the IM Fell cut
// that FONTS loads. Upright, it would need the roman, which FONTS
// leaves out; the layout would change only for a title long enough to wrap.
italic: true };
With breakBefore off, a letter starts two grid lines (marginTop) below the grid line where the one before ends. On page 4 the postscript, set on 12.6 pt leading, ends between grid lines, so about three lines of white stand above Letter III. On page 2, Letter I runs to the foot of the page and Letter II opens page 3. Left at its default, level 1 would open every letter on a recto (break before). numberingTemplate: '{1:I}' numbers the letters I to III, and the head prints the numeral through {number}.
#3 · Date the recto with the letter
const HEAD_Y = 12; // mm from the top edge
const head = (id, content, parity, placement, look = {}) => ({ kind: 'text', id, content,
parity, pages: 'body', ...sc, fontSize: pt(8.5), letterSpacing: pt(0.9), color: col('muted'),
placement, ...look });
const folio = { ...crimson, fontSize: pt(9), letterSpacing: pt(0), color: col('ink') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', at('page', 'top-left', MARGIN.outer, HEAD_Y), folio),
head('verso-names', '{author}', 'even', at('page', 'top-left', MARGIN.outer + 8, HEAD_Y)),
// {attr.date} reads the last letter that starts on or before the page.
head('recto-date', '{attr.date}', 'odd', at('page', 'top-right', -(MARGIN.outer + 8), HEAD_Y),
{ ...crimson, italic: true, fontSize: pt(9.5), letterSpacing: pt(0), inlineMarks: true }),
head('recto-folio', '{pageNumber}', 'odd', at('page', 'top-right', -MARGIN.outer, HEAD_Y),
folio),
] };
In a page header, {attr.date} takes the attribute of the last level-1 heading that starts on or before the page. Page 3 prints 12 juin 1740, and page 5, where Voltaire’s letter continues from page 4, prints 1er avril 1778 with its ordinal raised (text elements). The heads sit 12 mm below the top edge of the page, the folio on the outer margin and the words 8 mm further in. pages: 'body' keeps them off the cover, which counts as an opener because its heading spans the page. The date is set in the Crimson Pro italic of the dateline it repeats, and the names on the verso in the small capitals of the letter numbers.
#4 · Make the cover a heading
// The Markdown: # Mon sort \\ est changé {style="cover"}. The binding fills the page, so the
// design reserves all of it and the headnote starts on page 2.
const onCover = (y) => at('page', 'top', 0, y); // centred, y mm below the top edge
const LETTERS = { x: 12, y: 72, w: 116, h: 120 }; // mm: the photograph, inside the fillet
// numbered: false keeps the cover out of the count, so the first letter is I.
const cover = { id: 'cover', numbered: false,
// span: 'page' although the book has one column. Kept in the column, the design stops at
// the column's foot (a band of paper under the leather), and page 1 counts as a 'body' page
// and prints the running heads.
span: 'page', advancedDesign: { enabled: true, slot: { elements: [
{ kind: 'image', id: 'binding', resourceId: 'binding',
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } } },
{ kind: 'image', id: 'letters', resourceId: 'letters', placement: { ...at('page', 'top-left',
LETTERS.x, LETTERS.y), size: { width: mm(LETTERS.w), height: mm(LETTERS.h) } } },
{ kind: 'text', id: 'names', content: '{author}', ...sc, fontSize: pt(9.5),
letterSpacing: pt(2), color: col('gilt'), placement: onCover(18) },
// \\ in the heading breaks the title here.
{ kind: 'text', id: 'title', content: '{titleText}', ...fell, fontSize: pt(50),
lineHeight: 1, color: col('paper'), align: 'center', overflow: 'wrap',
placement: onCover(24) },
{ kind: 'text', id: 'subtitle', content: '{subtitle}', ...crimson, italic: true,
fontSize: pt(12), color: col('paper'), placement: onCover(62) },
] } } };
The cover is the first heading, in the cover heading style: an image element anchored to the bleed carries the drawn binding, a second one places the photograph 72 mm down, and the title, the names and the subtitle come from the heading and the frontmatter. numbered: false leaves it out of the count, so Frederick’s first letter is I. The binding image fills the page, and an opener reserves room down to its lowest element, so the cover takes the whole of page 1 and the headnote starts on page 2 with no :::pagebreak.
#5 · Hyphenate the French, and keep the spaces open
// Justification, hyphenation, whole-paragraph line breaking and the widow, orphan and runt
// rules are defaults; locale 'fr' (in the config) picks the French patterns.
// The letters keep the transcription's unspaced ; : ? and !; a narrow no-break space
// (U+202F) typed before each would give French spacing and never end a line.
const bodyText = { fontFamily: 'Crimson Pro', fontSize: pt(10), lineHeight: pt(LEAD),
color: col('ink'), firstLineIndent: mm(5),
// No :ref here: written out with the other colours, for the default-skin check.
referenceColor: col('ink'),
// A word space never shrinks below 75 % of the font's. At the default 60 %, the tightest
// line on page 5 sets its spaces at 0.70 (each VDT line carries its justifiedSpaceRatio).
minWordSpacing: 0.75 };
locale: 'fr' hyphenates with the French patterns (ou-vrage on page 2, représen-tation on page 4). Justification, whole-paragraph line breaking and the widow, orphan and runt rules are on by default. minWordSpacing: 0.75 stops a word space from shrinking below three quarters of Crimson Pro’s; at the default 0.6, the tightest justified line on page 5 would set its spaces at 0.70 of that width. At 14.4 pt leading the page holds 33 lines, and the bottom margin is what is left below them, 20.4 mm.
#6 · Link every colour to the palette
const palette = {
ink: '#2a2320', // the text: a warm near-black
paper: '#f6efe2', // the page, and the lettering on the cover
seal: '#9c2b24', // the letter numbers
leather: '#2a4536', // the cover: a green morocco binding
gilt: '#d0b67c', // its tooled border and the names on it
muted: '#75695d', // the running heads
};
// col(id): a colour linked to its palette entry, in text styles and design elements alike.
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 default colours, the italic of the headnote among them, link to 'main-color';
// here it is the ink, not the default blue.
{ id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
col() links each colour to its palette entry, and the link holds in the text styles and in the design elements alike: the letter heads, the running heads and the cover. The italic of the headnote and of the colophon takes the default italic colour, which is linked to main-color; with that entry set to the ink, it prints in ink and not in the engine’s blue, #295AA3.
The whole recipe
// ═══ Postext Cookbook · Nº 064 · Letters edition: datelines and signatures ════════════
// https://postext.dev/en/cookbook/letters-edition
// Code: MIT · Text: Frederick II and Voltaire, 1740 and 1778 (PD) · Cover photo: diffusion models
// Fonts: Crimson Pro, IM Fell French Canon, IM Fell DW Pica SC (SIL OFL) · 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 = 'letters-edition';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: iron-gall ink on cream paper, wax red, green morocco and gilt
const palette = {
ink: '#2a2320', // the text: a warm near-black
paper: '#f6efe2', // the page, and the lettering on the cover
seal: '#9c2b24', // the letter numbers
leather: '#2a4536', // the cover: a green morocco binding
gilt: '#d0b67c', // its tooled border and the names on it
muted: '#75695d', // the running heads
};
// col(id): a colour linked to its palette entry, in text styles and design elements alike.
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 default colours, the italic of the headnote among them, link to 'main-color';
// here it is the ink, not the default blue.
{ id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
// #endregion
const TRIM = { width: 140, height: 210 }; // the French 14 × 21 format
const LEAD = 14.4; // pt: the body's leading, the grid every letter starts on
const LINES = 33; // lines of text on a full page
const TOP = 22; // mm: the top margin
const MARGIN = { top: TOP, inner: 17.5, outer: 14.5, // mm, mirrored
bottom: TRIM.height - TOP - (LINES * LEAD * 25.4) / 72 }; // ends the page on line 33
const sc = { fontFamily: 'IM Fell DW Pica SC' }; // its lower case is cut as small capitals
const fell = { fontFamily: 'IM Fell French Canon', italic: true }; // the display italic
const crimson = { fontFamily: 'Crimson Pro' }; // the text face
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// #region answer: a letter head read from the heading, and styles for the letter's parts
// Each letter is a level-1 heading that carries its place and date as attributes:
// # Frédéric à Voltaire {place="À Charlottembourg" date="6 juin 1740"}
// (a value holds no { or }, and one with " goes in single quotes: gotcha attr-values)
const letterHead = { enabled: true, slot: { elements: [
// {number} prints the count as numberingTemplate '{1:I}' writes it.
{ kind: 'text', id: 'number', content: 'Lettre {number}', ...sc, fontSize: pt(9),
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
#Name the place in the running head
The same attributes can give the recto the whole dateline, À Charlottembourg, le 12 juin 1740.
- head('recto-date', '{attr.date}', 'odd', at('page', 'top-right', -(MARGIN.outer + 8), HEAD_Y),
+ head('recto-date', '{attr.place}, le {attr.date}', 'odd',
+ at('page', 'top-right', -(MARGIN.outer + 8), HEAD_Y),Pitfalls
Pitfall
Attribute values: no { or }; single-quote a value with "
An attribute value ends at the closing brace, so it cannot hold { or }. A value that contains a double quote goes in single quotes; a dollar sign is fine. Heading attributes →
- The recto takes the date of the last letter that starts on or before the page. A page that ends one letter and opens the next carries the new letter’s date, the way a dictionary’s running head names the last entry on the page.
- A heading without the attribute prints an empty string, with no warning: a letter without
place="…"gets a dateline that starts with a comma. Check the heading of every letter. - The letters keep the transcription’s unspaced ; : ? and !. French practice puts a narrow no-break space (U+202F) before them; typed there, it keeps each mark on the line of its word.
- Crimson Pro has no modifier letters ᵉ (U+1D49) or ʳ (U+02B3), so 1ᵉʳ spelled in Unicode would print in a fallback font. Write
1^er^instead: the headnote, which is body text, sets it as a superscript, and so do the dateline and the recto head, whose text elements carryinlineMarks: true.
Credits
- Recipe
- Ignacio Ferro
- Text
- Frederick II’s letters to Voltaire of 6 and 12 June 1740 and Voltaire’s letter to him of 1 April 1778, in Correspondance de Voltaire avec le roi de Prusse (Paris, Librairie de la Bibliothèque nationale, 1889), one misprint corrected (ouvragés), the salutations and signatures set apart · Frédéric II · Voltaire · public domain
- The headnote and the colophon · Ignacio Ferro · CC BY 4.0
- Images
- The cover: two folded letters and a wax seal, a photograph · Generated With Diffusion Models · original
- The cover’s green morocco and gilt fillet, drawn in code · Ignacio Ferro · CC BY 4.0
- Fonts
- Crimson Pro (SIL OFL 1.1) · IM Fell French Canon (SIL OFL 1.1) · IM Fell DW Pica SC (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


