かんたんな説明
プロイセン王とヴォルテールが交わした3通の手紙を収めた小さな本です。手紙ごとに日付、呼びかけ、署名を組み、新しいページを起こさずに手紙を続けて組む方法を示します。
できあがり
14 × 21cmの版『Mon sort est changé』の5ページで、フランス語の書簡3通を収めます。フリードリヒ2世がプロイセン王になって6日後と12日後、1740年6月にヴォルテールに宛てた2通と、ヴォルテールが死の2か月前、1778年4月1日に書いた手紙です。表紙では、拡散モデルで生成した、折りたたんだ2通の手紙と赤い封蝋の写真が、コードで描いた緑のモロッコ革の上、金の二重罫の内側に置かれています。本文では、手紙は改ページせずに続きます。各手紙の見出しは赤いスモールキャピタルの番号と、Fellのイタリックで組んだ差出人と宛先からなり、その下に場所と日付を右そろえで置きます。呼びかけは独立した1行を取り、スモールキャピタルの署名が右の余白で手紙を締めくくります。フリードリヒの追伸は署名のあとに1段小さく続きます。各奇数ページの柱には手紙の日付が入ります。
このレシピが答える質問
- エピグラフ、献辞、署名、大きな引用符の付いたプルクオートを組むには?
- スペイン語・フランス語・ドイツ語のテキストで、きれいな両端そろえとハイフネーションを得るには?
- 柱を設定するには(左ページに書名、右ページに章タイトル、ノンブルは小口側)?
手短な答え
// 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.
材料
- 機能
- 見出しの属性デザイン要素の基準位置段落スタイルデザインした章扉番号付き見出し奇数ページから始まる章見出しスタイル表紙、扉、奥付ページデザインの画像タイトル内の改行柱とノンブル行ごとの詩見開きの余白用紙の色ハイフネーションと文書の言語上付きと下付き文書のメタデータセマンティックカラーパレットキャンバス上のページ
- 種類
- Crimson Pro, IM Fell French Canon, IM Fell DW Pica SC (SIL OFL 1.1)
- 素材
letters-1160.jpg- The cover: two folded letters and a wax seal, a photograph (Generated With Diffusion Models, オリジナル)
- The cover’s green morocco and gilt fillet, drawn in code (Ignacio Ferro, CC BY 4.0)
作り方
#1 · 日付行を見出しから読む
コードは上の手短な答えにあります。手紙はそれぞれレベル1の見出しで、その属性に場所と日付を書き、見出しのデザインがそれを{attr.place}, le {attr.date}.として印刷します(見出しの属性)。日付行の箱は段の右端まで届き(width: 'fill')、align: 'right'が語をその端にそろえます。これがないと、デザインのテキストは中央にそろいます。呼びかけ、署名、追伸は:::paragraphs{style="…"}で適用する段落スタイルです。署名には、小文字をスモールキャピタルとして作ったファミリーIM Fell DW Pica SCを使います。inlineMarks: trueを付けた日付行は属性の中のマークを解釈するので、date="1^er^ avril 1778"と書けば序数の語尾が上付きになります。
#2 · 手紙を続けて組む
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 };
breakBeforeを切ると、手紙は前の手紙が終わるグリッド線の2本下(marginTop)から始まります。4ページでは、12.6ptの行送りで組んだ追伸がグリッド線のあいだで終わるので、第3の手紙の上に約3行分の白が立ちます。2ページでは第1の手紙がページの末尾まで続き、第2の手紙が3ページを始めます。レベル1の既定値のままだと、どの手紙も奇数ページから始まります(前で改ページ)。numberingTemplate: '{1:I}'で手紙にIからIIIの番号が振られ、見出しは{number}でその数字を印刷します。
#3 · 奇数ページに手紙の日付を入れる
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),
] };
ページのヘッダーでは、{attr.date}は、そのページかそれより前で始まる最後のレベル1の見出しの属性を取ります。3ページには12 juin 1740が入り、4ページから続くヴォルテールの手紙の5ページには、序数の語尾を上付きにした1er avril 1778が入ります(テキスト要素)。柱はページの上端から12mm下に置き、ノンブルは小口側の余白に、語はそこから8mm内側に置きます。pages: 'body'は柱を表紙から外します。表紙は見出しがページ全幅にまたがるので、章扉として数えられます。日付は、それが繰り返す日付行と同じCrimson Proのイタリックで組み、偶数ページの名前は手紙の番号と同じスモールキャピタルで組みます。
#4 · 表紙を見出しにする
// 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) },
] } } };
表紙は最初の見出しで、coverの見出しスタイルを使います。塗り足しに固定した画像要素が描いた装丁を載せ、2つ目の画像要素が72mm下に写真を置き、題、名前、副題は見出しとフロントマターから取ります。numbered: falseで表紙は番号の数に入らないので、フリードリヒの最初の手紙がIになります。装丁の画像はページいっぱいに広がり、章扉はいちばん下の要素までの高さを確保するので、表紙は1ページをまるごと占め、解題は:::pagebreakなしで2ページから始まります。
#5 · フランス語をハイフネーションし、語間を開いておく
// 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'はフランス語のパターンでハイフネーションします(2ページのou-vrage、4ページのreprésen-tation)。両端そろえ、段落全体での改行、ウィドウ、オーファン、ラントの規則は既定で有効です。minWordSpacing: 0.75は、語間がCrimson Proの語間の4分の3より縮まないようにします。既定の0.6では、5ページで最も詰まった両端そろえの行の語間が、その幅の0.70になります。14.4ptの行送りでページには33行が入り、地の余白はその下に残る20.4mmです。
#6 · すべての色をパレットにつなぐ
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()は各色をパレットの項目にリンクします。このリンクはテキストのスタイルでもデザインの要素でも同じように働きます。手紙の見出し、柱、表紙がそうです。解題と奥付のイタリックは既定のイタリックの色を使い、これはmain-colorにつながっています。この項目を墨色にすると、イタリックはエンジンの青(#295AA3)ではなく墨色で印刷されます。
レシピの全体
// ═══ 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),
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#柱に場所も入れる
同じ属性を使えば、奇数ページに日付行全体、「À 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),よくあるつまずき
つまずき
属性値には{も}も書けない。"を含む値は一重引用符で囲む
属性値は閉じ波かっこで終わるため、{や}を含められません。二重引用符を含む値は一重引用符で囲みます。ドル記号は問題ありません。 見出しの属性 →
- 奇数ページは、そのページかそれより前で始まる最後の手紙の日付を取ります。ある手紙が終わり次の手紙が始まるページには、新しい手紙の日付が入ります。辞書の柱がそのページの最後の見出し語を示すのと同じです。
- 属性のない見出しは空文字列を印刷し、警告も出ません。
place="…"のない手紙では、日付行がコンマから始まります。すべての手紙の見出しを確認してください。 - 手紙は翻刻のとおり、; : ? !の前にアキを入れていません。フランス語の慣行ではその前に細いノーブレークスペース(U+202F)を入れます。これを入力すれば、約物は前の語と同じ行にとどまります。
- Crimson Proには修飾文字のᵉ(U+1D49)とʳ(U+02B3)がないので、Unicodeで綴った1ᵉʳは代替フォントで印刷されます。代わりに
1^er^と書きます。本文である解題はこれを上付きで組み、日付行と奇数ページの柱も、テキスト要素にinlineMarks: trueがあるので同じように組みます。
クレジット
- 本文
- 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 · パブリックドメイン
- The headnote and the colophon · Ignacio Ferro · CC BY 4.0
- 画像
- The cover: two folded letters and a wax seal, a photograph · Generated With Diffusion Models · オリジナル
- The cover’s green morocco and gilt fillet, drawn in code · Ignacio Ferro · CC BY 4.0
- フォント
- Crimson Pro (SIL OFL 1.1) · IM Fell French Canon (SIL OFL 1.1) · IM Fell DW Pica SC (SIL OFL 1.1)


