かんたんな説明
博士論文の最後のページ、最終章から索引までです。Postextは本文中で印を付けた言葉から索引を作り、ページ番号を自分で入れます。
できあがり
画面と紙での読書を扱う博士論文の最後の7ページを、B5判に白黒で組みます。第6章、付録A、用語集、文献一覧、索引は、どれも同じ深さ62 mmの黒い帯の下で始まり、タイトルは帯から白抜きにします。章は帯に数字を、付録は文字を示し、後付けの各節はキッカーBACK MATTERと短いイタリックの注記を載せます。章は両端そろえの1段組みです。用語集と索引は左そろえの2段組みに切り替わり、文献一覧は1段に戻り、どの項目も折り返し行を字下げします。索引は本文中の印から作ります。エンジンが用語を見出し文字の下に並べ、印ごとのページを見つけ、連続するページを171–73のような範囲にまとめます。太字の番号は用語集の定義を指します。
このレシピが答える質問
- 参考文献や用語集を組むには(ぶら下げインデント、小さめの文字)?
- 本文が動くと自動でノンブルが変わる索引を作るには?
- 見出し、太字、箇条書きの記号が青く出ないようにするには?
- 見出しに番号(1、1.1、1.1.1)を振り、レベルごとに異なるスタイルにするには?
- 柱を設定するには(左ページに書名、右ページに章タイトル、ノンブルは小口側)?
- 改ページや改段を強制し、すべての章を右ページから始めるには?
手短な答え
// '# Glossary {style="glossary"}' in the Markdown picks a style. Each style starts a page
// of either parity, the appendix a recto (a style that sets no break inherits its level's
// 'odd': gotcha style-inherits-break), stays out of the chapter count (numbered: false, so
// its band has no numeral) and brings its own running heads; the glossary and the index
// set their pages in two columns until the next '#'. The appendix counts, in letters: its
// template prints the level's counter as A, B… config() takes both lists below.
const twoColumns = { layoutType: 'double', gutterWidth: mm(6) };
const backMatter = (id, extra) => ({ id, numbered: false, breakBefore: { enabled: true,
parity: 'any' }, advancedDesign: opener('Back matter'), header: sectionHeads, ...extra });
const headingStyles = () => [
backMatter('appendix', { numbered: true, numberingTemplate: '{1:A}', header: appendixHeads,
breakBefore: { enabled: true, parity: 'odd' }, advancedDesign: opener('Appendix') }),
backMatter('glossary', { layout: twoColumns }),
backMatter('references'),
backMatter('index', { layout: twoColumns }),
];
// One paragraph per entry, in :::paragraphs{style="…"}: the turnover lines hang, so the
// first word of every entry stands clear at the left. Ragged, as APA asks of references,
// with every word whole (hyphenation.ragged is off). The index has its own settings.
const entries = (id, size, lead, hang, extra) => ({ id, fontSize: pt(size),
lineHeight: pt(lead), textAlign: 'left', hangingIndent: em(hang), ...extra });
const paragraphStyles = () => [
entries('term', 9.3, 12.4, 1), // the glossary: a bold term, then its definition
entries('reference', 9.3, 12.4, 1.5, { spaceBetween: pt(2.4) }),
];
材料
- 機能
- 節ごとのページ構成参考文献と用語集番号のない章索引節ごとの柱見出しスタイル番号付き見出し奇数ページから始まる章段抜きの章見出し帯デザインした章扉見出しの属性ページの役割ごとの柱段落スタイル独自のリソースの種類図を配置する参照データから作る表キャプションのスタイルセマンティックカラーパレット太字・イタリックとその色PDFの書き出し
- 種類
- Libertinus Serif, Libertinus Serif Display, Libertinus Sans (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 後付けの各部に見出しスタイルを与える
コードは上の手短な答えにあります。# Glossary {style="glossary" note="…"}は次のレベル1見出しまで続く節を開き、そのページはスタイルのレイアウト、柱、章扉を取ります(見出しスタイル)。そのため用語集と索引は2段組みに切り替わり、レイアウトを指定しないスタイルの文献一覧は文書の1段組みに戻ります。numbered: falseはこれらの見出しを章の数から外します(消すと、用語集の帯に2が印刷されます)。また、スタイルはそれぞれ自分の改ページを指定します。指定しないスタイルは章の'odd'を引き継ぎ、白の偶数ページを残すからです。用語集と文献一覧の項目は:::paragraphs{style="…"}ブロックの段落で、本文の11/14.6 ptに対して9.3/12.4 ptで組み、折り返し行は用語集で1em、文献一覧で1.5 emのぶら下げです(段落スタイル)。
#2 · すべての章扉に同じ帯を描く
const SINK = 8; // lines reserved, 41.2 mm: 3.2 mm more than the band, and text on the grid
// Design text sets each baseline 0.8 of its line under the line's top, and a line is 1.2 × the
// size unless lineHeight says otherwise. In mm, a line's part above its baseline and below it:
const PT = 25.4 / 72;
const above = (size, lineHeight = 1.2) => 0.8 * size * lineHeight * PT;
const below = (size, lineHeight = 1.2) => 0.2 * size * lineHeight * PT;
const KICKER = 4.3, TITLE = BAND - TOP - 9.5; // mm under the text block's top: two baselines
// A bottom-aligned box that ends below() under a baseline sets its last line on it. The
// numeral's line is 0.72 of its size, so the line fits inside its box.
const text = (id, content, family, size, lineHeight, baseline, edge, w, extra) => ({
kind: 'text', id, content, fontFamily: family, fontSize: pt(size), lineHeight,
color: col('paper'), overflow: 'wrap', align: edge.endsWith('right') ? 'right' : 'left',
verticalAlign: 'bottom', ...extra, placement: { anchor: { to: 'container', edge },
size: { width: mm(w), height: mm(baseline + below(size, lineHeight)) } } });
// The mark is '{number}': the chapter's 6, the appendix's A, nothing on an unnumbered heading.
const opener = (label) => ({ enabled: true, minHeight: pt(SINK * LEAD),
slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('band') }, placement: {
anchor: { to: 'page', edge: 'top-left' }, size: { width: 'fill', height: mm(BAND) } } },
text('label', label, LABEL, 8, 1.2, KICKER, 'top-left', 80,
{ fontWeight: 700, letterSpacing: pt(1.6), textTransform: 'uppercase' }),
text('title', '{titleText}', DISPLAY, 34, 1.04, TITLE, 'top-left', 84),
text('mark', '{number}', DISPLAY, 118, 0.72, TITLE, 'top-right', 34),
text('note', '{attr.note}', TEXT, 8.6, 1.3, TITLE, 'top-right', 44, { italic: true }),
] } });
マークは{number}です。章では6、付録ではA、番号なしの見出しでは空になります。そのため1つのデザインで、章、付録、数字の位置に{attr.note}を印刷する後付けの各節をまかなえます。minHeightは14.6 ptの8行分、版面の上端から41.2 mmを確保します。これで帯から3.2 mm離れ、本文がグリッドに載ったままになります。デザインテキストはベースラインを行の0.8の位置に置くので、下端をベースラインのbelow()に置いた下そろえのボックスは、最終行をそのベースラインに載せます。タイトル、118 ptの数字、注記の最終行は、すべて仕上がり線から52.5 mm下のタイトルのベースラインに立ちます。数字の行送りは文字サイズの0.72で、行がボックスに収まります。
#3 · 付録の文字はスタイルが付ける
// The style's '{1:A}' (see answer) prints the level's counter as a letter, and startAt=1 on the
// first appendix restarts it after chapter 6. The band and the running head read that letter.
// A resource template's {h1} is a number unless it names a style: '{h1:A}.{n}' counts the
// tables A.1, A.2… and B.1 in a second appendix, with one type for all of them.
const appendixHeads = heads('Appendix {chapterNumber}. {chapterTitle}');
const appendixTables = { ...defaultResourceTypes(LANG).find((type) => type.id === 'table'),
id: 'table-a', numberingTemplate: '{h1:A}.{n}', resetOn: 'h1' }; // a copy of 'table'
付録のスタイルはnumberingTemplate: '{1:A}'を指定し、レベルのカウンターを文字で印刷します。# Interview guide {style="appendix" startAt=1}がそのカウンターを振り直すので、最初の付録はGではなくAになります(見出しスタイル)。帯は{number}で、柱は{chapterNumber}でこの文字を参照します。リソースタイプの{h1}は、書式を指定しないかぎりカウンターを数字で印刷するので、付録の表にはテンプレートが'{h1:A}.{n}'のタイプを使います。A.1、A.2…となり、2つ目の付録ではB.1になります。既定のタイプでは、この表は表1.1になります。章自身の見出しはレベルのテンプレートで数えます。'{1}.{2}'は6.1を印刷し、continuation.headings.h1: 5がこの章を第6章にします。
#4 · 柱を小口側に置く
const HEAD = 17.5, GAP = 9; // mm: the heads' baseline under the trim; the folio to the words
// Each text is placed by its top, above() over HEAD: the folio and the capitals share a baseline.
const head = (id, content, parity, edge, x, size = 7.5, extra) => ({ kind: 'text', id, content,
parity, pages: 'body', fontFamily: LABEL, fontSize: pt(size), fontWeight: 700,
letterSpacing: pt(1.3), textTransform: 'uppercase', color: col('ink'), ...extra, placement: {
anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(HEAD - above(size)) } } });
const folio = { fontFamily: TEXT, fontWeight: 400, letterSpacing: pt(0) };
const heads = (recto) => ({ elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, 9.5, folio),
head('verso', '{title}', 'even', 'top-left', OUTER + GAP),
head('recto', recto, 'odd', 'top-right', -(OUTER + GAP)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, 9.5, folio),
// The header's container spans the text block, so one rule serves both pages.
{ kind: 'rule', id: 'hairline', pages: 'body', direction: 'horizontal', thickness: pt(0.5),
color: col('rule'), placement: { anchor: { to: 'container', edge: 'top-left' },
offset: { y: mm(HEAD + 2) }, size: { width: 'fill' } } },
] });
const chapterHeads = heads('Chapter {chapterNumber}. {chapterTitle}');
const sectionHeads = heads('{chapterTitle}'); // 'Glossary', 'References', 'Index'
// Openers drop the folio to the foot, centred under the text block, its baseline 12 mm below.
const footer = { elements: [{ kind: 'text', id: 'drop-folio', content: '{pageNumber}',
pages: 'opener', ...folio, fontSize: pt(9.5), color: col('ink'), align: 'center',
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(12 - above(9.5)) } } }] };
4つのテキスト要素はページに固定し、parityで絞り込むので、ノンブルはどちらのページでも小口側にとどまります。各要素は上端で配置し、仕上がり線から17.5 mm下のベースラインのabove()に置くので、9.5 ptのノンブルと7.5 ptのキャピタルが1本の行に並びます。偶数ページには論文のタイトル(フロントマターの{title})、奇数ページには節のタイトル({chapterTitle})が入り、177ページならINDEXです。pages: 'body'はこれらを章扉から外し、章扉にはフッターのノンブルだけが版面の下の中央に付きます。章の奇数ページなら「Chapter 6. Conclusion」、付録なら「Appendix A. Interview guide」となるはずですが、この見本で奇数ページまで続くのは索引だけです。
#5 · 本文が用語を論じている箇所に印を付ける
// Glossary definitions carry 'main' (bold numbers); runs of pages join as 171–72 (Chicago).
// The heads stand on the entries' 11.6 pt pitch, 7.5 pt of space above them: 19 pt from the
// last entry of a letter to the next letter's baseline, 11.6 pt from a letter to its first entry.
const index = { fontFamily: TEXT, fontSize: pt(9), lineHeight: pt(11.6), color: col('ink'),
indent: em(1), turnoverIndent: em(2), rangeFormat: 'chicago',
groups: { fontFamily: DISPLAY, fontSize: pt(13), fontWeight: 400, color: col('ink'),
marginTop: pt(7.5) } };
:index[tablet]はその語を印刷し、同じ語で索引に登録します。Rayner:index{term="Rayner, Keith"}は何も印刷せず、「Rayner」のページをフルネームの下に登録します。term="interviews!timing of"は下位項目を作ります。用語集の用語にはmainが付いているので、そのページは太字になります。索引の帯の注記が述べているとおりです。# Index {style="index"}の下の:::indexは、スタイルの2段組みで項目を印刷し、buildDocumentはページ番号が動かなくなるまで文書を組み直します。項目は9/11.6 ptで、折り返し行は2emのぶら下げ、下位項目は1em字下げし、見出し文字はディスプレイ書体の13 ptです。印は表のセルの中では働かないので、表6.1の行はページを加えません。「look-backs」は表ではなく、それを報告する段落のページを示します。
#6 · 既定の色をすべてインクにする
const palette = { ink: '#000000', band: '#000000', rule: '#000000', paper: '#ffffff' };
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// Bold, italic and list markers default to 'main-color': pointed at the ink, they print black.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
太字、イタリック、リストの記号、参照についてのエンジンの既定値は、パレットの項目main-colorに従うので、これをインキの色に向けると、青ではなく黒で印刷されます(カラーパレット)。referenceBold: falseは、「Table 6.1」を周りの著者・年方式の引用と同じくローマン体で組みます。
レシピの全体
// ═══ Postext Cookbook · Nº 031 · Thesis back matter: appendix, glossary and index ═══
// https://postext.dev/en/cookbook/thesis-back-matter
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Libertinus Serif, Serif Display and Sans (SIL OFL 1.1) · Needs postext ≥ 1.28.0
import {
buildDocumentWithFonts, renderPageToCanvas, defaultResourceTypes,
} 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')
const RECIPE = 'thesis-back-matter';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: one ink; every colour is black or white, each under its own name
const palette = { ink: '#000000', band: '#000000', rule: '#000000', paper: '#ffffff' };
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// Bold, italic and list markers default to 'main-color': pointed at the ink, they print black.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const TEXT = 'Libertinus Serif', DISPLAY = 'Libertinus Serif Display', LABEL = 'Libertinus Sans';
const TOP = 24, INNER = 25, OUTER = 31; // mm: a 120 mm measure, about 70 characters at 11 pt
const LEAD = 14.6; // pt: the body's leading, the grid every page is set on
const BAND = 62; // mm from the trim's top: the black band at the head of every opener
// #region answer: back matter as unnumbered heading styles, entries in hanging indents
// '# Glossary {style="glossary"}' in the Markdown picks a style. Each style starts a page
// of either parity, the appendix a recto (a style that sets no break inherits its level's
// 'odd': gotcha style-inherits-break), stays out of the chapter count (numbered: false, so
// its band has no numeral) and brings its own running heads; the glossary and the index
// set their pages in two columns until the next '#'. The appendix counts, in letters: its
// template prints the level's counter as A, B… config() takes both lists below.
const twoColumns = { layoutType: 'double', gutterWidth: mm(6) };
const backMatter = (id, extra) => ({ id, numbered: false, breakBefore: { enabled: true,
parity: 'any' }, advancedDesign: opener('Back matter'), header: sectionHeads, ...extra });
const headingStyles = () => [
backMatter('appendix', { numbered: true, numberingTemplate: '{1:A}', header: appendixHeads,
breakBefore: { enabled: true, parity: 'odd' }, advancedDesign: opener('Appendix') }),
backMatter('glossary', { layout: twoColumns }),
backMatter('references'),
backMatter('index', { layout: twoColumns }),
];
// One paragraph per entry, in :::paragraphs{style="…"}: the turnover lines hang, so the
// first word of every entry stands clear at the left. Ragged, as APA asks of references,
// with every word whole (hyphenation.ragged is off). The index has its own settings.
const entries = (id, size, lead, hang, extra) => ({ id, fontSize: pt(size),
lineHeight: pt(lead), textAlign: 'left', hangingIndent: em(hang), ...extra });
const paragraphStyles = () => [
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#どの節も奇数ページから始める
図書館に納める学位論文では、各節を右ページから始めることがよくあります。その場合、用語集、文献一覧、索引は、それぞれ白の偶数ページの後の175、177、179ページへ移り、索引の太字の番号は175ページを指します。
-const backMatter = (id, extra) => ({ id, numbered: false, breakBefore: { enabled: true,
- parity: 'any' }, advancedDesign: opener('Back matter'), header: sectionHeads, ...extra });
+const backMatter = (id, extra) => ({ id, numbered: false, breakBefore: { enabled: true,
+ parity: 'odd' }, advancedDesign: opener('Back matter'), header: sectionHeads, ...extra });#論文の前付けも組む
1ページ目の前にローマ数字で数える前付けは、前付けはローマ数字、本文は1ページからにあります。
よくあるつまずき
つまずき
見出しスタイルはその階層の改ページを受け継ぐ
headingStylesの項目は、指定しなかったフィールドをすべて見出しの階層から受け継ぎ、breakBeforeも例外ではありません。:::pagebreakのあとのH1に付けた目次や奥付のスタイルはparity 'odd'を受け継ぎ、白ページの後ろに置かれます。こうしたスタイルにはbreakBefore: { enabled: false }を指定してください。 見出しスタイル →
つまずき
1ページは奇数ページ。ページは物理的な番号で計画する
1ページは右ページで、2ページが最初の偶数ページです。見開きは物理的なページ番号で計画してください。偶数ページの章扉は、その次の奇数ページと向かい合います。 改ページと改段 →
クレジット
- 本文
- 書き下ろしの文章, CC BY 4.0
- フォント
- Libertinus Serif (SIL OFL 1.1) · Libertinus Serif Display (SIL OFL 1.1) · Libertinus Sans (SIL OFL 1.1)


