本文へスキップ
レシピ番号45

レシピ集 · 第3章 · 見出しと章扉

欄外見出し、ぶら下げ番号、追い込み見出し

設計競技の募集要項。節の題は余白の欄に本文のベースラインに合わせて立ち、小節の番号は段間にぶら下がり、追い込み見出しは赤で入ります。

このページの内容

1ページ(全5ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり210 × 297 mm
  • 1段半組み, 段間7 mm
  • Mona Sans 10/14
  • DM Mono
  • Mona Sans@tnum
  • Noto Serif Display
  • 5ページ
  • レベル
  • Postext 1.65.0
  • 組版時間86 ms
  • コード263行

かんたんな説明

古い魚市場を図書館に変える設計案を、町議会が募集する要項です。節の題は広い左の余白に置かれ、隣の本文の1行目と同じ高さにそろいます。

できあがり

建築設計競技の募集要項をA4判5ページに組みます。スペインの架空の港町Puerto Linceの議会が、1931年の魚市場を町の図書館に変える設計案を募るものです。レイアウトはスイスの自治体の報告書にならいます。どのページにも左側を50 mmの余白欄が縦に走り、各節は赤い番号と版面全体にわたる黒い罫で始まります。節の題はNoto Serif Displayで欄に立ち、本文の1行目と同じ高さにそろいます。小節の番号は赤いDM Monoで段間にぶら下がるので、小節の題はどれも本文の左端をそろえて保ちます。第4節の審査基準は赤い太字の語で始まります。1ページ目は敷地図の上に58 ptの題を置き、2ページ目には敷地の平面図が欄に立ち、3ページ目は岸壁側の立面図で始まります。

このレシピが答える質問

  • 見出しに番号(1、1.1、1.1.1)を振り、レベルごとに異なるスタイルにするには?
  • 幅の広い本文の段と幅の狭いサイド段からなる1段半のレイアウトにするには?
  • 図の位置を制御するには(ページの上端、2段をまたぐ、まさにこの位置、余白)?
  • 本文や囲みの中で、キーワード(太字やイタリック)に色を付けるには?

手短な答え

script.js · 56〜81行コード全体で見る
// The heading stays in the flow and keeps its number, but its design has no {titleText}:
// it prints the number in the channel and a rule from there to the column's right edge,
// both reserve: false, or the box below would keep a float gap under them (a line lower).
const [NUMBER, RULE] = [8.5, 0.75]; // pt: the DM Mono number, whose figures are 0.7 em tall
// Centre the rule on the figures: their baseline is 0.8 of the line down, less 0.35 em.
const RULE_Y = pt(NUMBER * (0.8 - 0.7 / 2) - RULE / 2);
const h2 = { level: 2, numberingTemplate: '{2}', lineHeight: pt(LEAD), // one grid line
  marginTop: pt(2 * LEAD), marginBottom: pt(0), advancedDesign: { enabled: true, slot: {
    elements: [
      { kind: 'text', id: 'number', content: '{number}', fontFamily: LABEL, fontWeight: 500,
        fontSize: pt(NUMBER), lineHeight: 1, color: col('signal'), reserve: false,
        placement: at('container', 'top-left', mm(-HANG)) },
      { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(RULE), reserve: false,
        color: col('ink'), placement: { ...at('#number', 'right-of', mm(2), RULE_Y),
          size: { width: 'fill' } } },
    ] } } };
// The title goes in a box fenced right after the heading: span="side" stands it in the
// channel on the grid line where the text resumes (gotcha: side-box-starts-at-fence).
// Attributes at the end of the line stay with the heading.
const sideHeads = (md) => md.replace(/^## (.+?)(\s*\{[^}]*\})?$/gm,
  (line, title) => `${line}\n\n:::callout{type="sidehead" span="side"}\n${title}\n:::`);
// The box has no background and no padding, and it takes the text's leading, so each
// line of the title sits on a baseline of the text beside it.
const sidehead = { id: 'sidehead', backgroundEnabled: false,
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  body: { fontFamily: DISPLAY, fontSize: pt(13.5), lineHeight: pt(LEAD) } };

材料

種類
Mona Sans, Noto Serif Display, DM Mono (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · 節の題は欄の中の囲みから印刷する

コードは上の手短な答えにあります。見出しはデザインのいちばん下の要素までの高さを確保するので、節の1行目と同じ高さで欄に題を描くと、本文が1行、2行の題なら2行押し下げられます。そこで見出しのデザインには番号と罫だけを描かせ、sideHeads()が各## Titleのテキストを、見出しの直後に置いた:::calloutブロックへ写します。span="side"にするとその囲みは流れを離れ、本文が再開するグリッド線の位置で欄に立ちます(囲みスタイル)。番号と罫線はreserve: falseにします。そうしないと、欄に立つ見出しの要素の下に囲みが1行分のフロートの間隔を空け、題が本文の2行目まで下がります。囲みと本文はどちらも行のベースラインを行送りの0.8倍下に置くので、本文の14 ptの行送りに乗った囲みは、2行の題の各行を隣の段落のベースラインにそろえます。Markdownはふつうの## Schedule of accommodationのままです。見出しのデザインが{titleText}を印刷しないため、囲みが題を印刷していても、Sandboxは警告「見出しのタイトルを参照していません」を表示します。

2ページ目。番号と罫は見出しから、題は欄の中の囲みから来て、本文の1行目と同じ高さに並びます。敷地の平面図はその下に積まれます。

#2 · 欄は見出しと図のために空けておく

script.js · 46〜52行コード全体で見る
const layout = {
  layoutType: 'oneAndHalf',
  sideColumnPercent: (SIDE / CONTENT) * 100, // 50 of the 178 mm between the margins
  sideColumnSide: 'left', // on every page: the brief is printed on one side of the sheet
  sideColumnRole: 'floats', // no text in the channel: what span: 'side' sends, side captions
  gutterWidth: mm(GUTTER),
};

sideColumnRole: 'floats'で本文は欄に入りません(レイアウトの種類)。章扉の後、欄に入るのは6つの節の題と敷地の平面図(どちらもspan: 'side'で送る)、そして表1と表2のキャプションだけです。サイド段の初期値は'right'で、紙の片面に刷る要項なら、どのページでも同じ側に置かれます。sideColumnSide: 'left'はそれを左に置き、各節の題が本文より先に読まれるようにします。

#3 · 番号をぶら下げ、いちばん小さな見出しを追い込みにする

script.js · 85〜102行コード全体で見る
// The title keeps the text's left edge; the number, right-aligned in a 12 mm box, ends
// 2 mm short of it. The box needs that fixed width: an 'auto' width is clamped to the
// column and would shrink to nothing out here.
const H3 = { size: 10.5, number: 9 }; // pt; two boxes one grid line tall share a baseline
const h3 = { level: 3, numberingTemplate: '{2}.{3}', fontSize: pt(H3.size),
  lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0),
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: TEXT, fontWeight: 600,
      fontSize: pt(H3.size), lineHeight: LEAD / H3.size, color: col('ink'), align: 'left',
      overflow: 'wrap', placement: { ...at('container', 'top-left'), size: { width: 'fill' } } },
    { kind: 'text', id: 'number', content: '{number}', fontFamily: LABEL, fontWeight: 500,
      fontSize: pt(H3.number), lineHeight: LEAD / H3.number, color: col('signal'),
      align: 'right', placement: { ...at('#title', 'left-of', mm(-2)),
        size: { width: mm(12) } } },
  ] } } };
// Level 4 is not a heading: '**Accessibility.** A wheelchair user…' opens its paragraph.
// No other paragraph has bold; table cells keep tableStyle's ink, so Total stays black.
const runIn = { boldColor: col('signal') }; // spread into bodyText

小節の題は段の左端から始まります。番号は題の'left-of'に固定し、本文の2 mm手前で終わる12 mmの箱の中で右そろえにするので、2.1や3.3のような番号は段間にぶら下がり、題はどれもその下の本文とそろいます(要素の配置)。箱には固定の幅が必要です。'auto'の幅は段に収まるよう切り詰められ、段間に出た位置では幅がまったく残らず、番号が描かれません。レベル2は'{2}'、レベル3は'{2}.{3}'を印刷します。{1}を使うと、要項に1つだけあるH1の1がすべての番号の頭に付いてしまうからです。第4節の基準は見出しなしで組む4番目のレベルです。各段落は太字の語で始まり、bodyText.boldColorがそれを赤で印刷します(本文)。ほかの段落には太字がなく、表のセルは色をtableStyleから取るので、表1の太字のTotalの行は黒のままです。

#4 · 図と表にそれぞれの配置を与える

script.js · 335〜369行コード全体で見る
// The plot plan stands in the channel; the elevation crosses channel and column at the
// head of the next page; the table of areas floats to the head of the text column, with
// its caption beside it in the channel; the timetable sits where ::resource puts it, and
// its caption takes the channel too (captionSide serves an inline embed from 1.28).
const PLAN_W = 44; // mm: the plot plan, 88 m wide at 1:2000
const resource = (id, typeId, rest) => ({ id, typeId, createdAt: 0, updatedAt: 0, ...rest });
const drawing = (id, width, height, rest) => resource(id, 'figure', { kind: 'svg',
  svg: { fileId: `${id}.svg`, width, height }, ...rest });
const resources = [
  drawing('parcela', PLAN_W * 10, 400, {
    placement: { span: 'side', width: PLAN_W / SIDE }, // 44 mm of the channel's 50
    caption: t({ en: 'The plot, 1:2000. Market hall and weighbridge hut in grey; six tamarisks '
      + 'along the north edge. Red arrows: possible entrances; grey arrow: service.',
    es: 'La parcela, 1:2000. Lonja y caseta de básculas, en gris; seis tamarindos en el '
      + 'borde norte. Flechas rojas: accesos posibles; flecha gris: servicio.' }),
    altText: t({ en: 'Plan of the plot with the hall, the hut, six trees and three entrances.',
      es: 'Planta de la parcela con la lonja, la caseta, seis árboles y tres accesos.' }) }),
  drawing('fachada', 1780, 300, { placement: { position: 'top', span: 'page' },
    caption: t({ en: 'Quay front, 1:300. In red, the four frames at the east end, where the '
      + 'reinforcement has corroded.',
    es: 'Fachada al muelle, 1:300. En rojo, los cuatro pórticos del extremo este, con '
      + 'las armaduras corroídas.' }),
    altText: t({ en: 'Elevation of the hall: thirteen vaults, eleven arches, four frames in red.',
      es: 'Alzado de la lonja: trece bóvedas, once arcos y cuatro pórticos en rojo.' }) }),
  resource('programa', 'table', { kind: 'table', table: { ...programme, styleId: 'figures' },
    placement: { position: 'top', captionSide: true }, caption: t({
      en: 'Schedule of net floor areas.', es: 'Programa de superficies útiles por zonas.' }) }),
  resource('calendario', 'table', { kind: 'table', table: calendar,
    placement: { position: 'here', captionSide: true },
    caption: t({ en: 'Competition timetable.', es: 'Calendario del concurso.' }) }),
  // No :ref cites the site plan: only the opener's image element draws it.
  drawing('situacion', MAP.w * 10, MAP.h * 10, { altText: t({
    en: 'Site plan of the Poniente quay with the market hall’s plot in red.',
    es: 'Plano de situación del muelle de Poniente con la parcela de la lonja en rojo.' }) }),
];

敷地の平面図はspan: 'side'で欄に入り、第2節の欄外見出しの下に積まれます(配置)。width: PLAN_W / SIDEで幅は44 mmになり、88メートルがちょうど1:2000になります。正面の立面図はページ幅の'top'フロートです。2ページ目で参照され、3ページ目の頭に入ります。フロートが参照箇所より前に置かれることはないからです。所要室の表も2ページ目で参照され、3ページ目の本文の段の頭、立面図の下にフロートします。captionSide: trueはキャプションを表の上端の高さで欄に立てます。日程表は::resourceの位置、要項の末尾に置かれ、captionSide: trueでそのキャプションも6.3項の横の欄に立ちます。Mona Sansの既定はプロポーショナル数字なので、右揃えの列では120と560の桁がそろいません。名前付きの表スタイルtableStyles: [{ id: 'figures', figureStyle: 'tabular' }]を表1がstyleId: 'figures'で選び、フォントのtnumをかけます。この等幅数字はスラッシュ付きのゼロで、DM Monoの番号に近い形です。日程表の日付はフォント本来の数字のままです(数字のスタイル)。

#5 · 要項を敷地図で始める

script.js · 106〜131行コード全体で見る
const MAP = { y: 68.5, w: CONTENT, h: 52 }; // mm: from the top of the text block
const display = { fontFamily: DISPLAY, fontWeight: 300, color: col('ink'), align: 'left',
  overflow: 'wrap' };
const opener = { enabled: true,
  // The plan's foot falls between two grid lines. A floor on the next one leaves the rule
  // of section 1 as far from its text as the rule of every later section.
  minHeight: mm(GRID * Math.ceil((MAP.y + MAP.h) / GRID)),
  slot: { elements: [
    { kind: 'text', id: 'kicker', content: '{attr.kicker}', ...label, color: col('signal'),
      placement: at('container', 'top-left', mm(HANG)) },
    { kind: 'text', id: 'series', content: '{subtitle}', ...label,
      placement: { ...at('container', 'top-left'), size: { width: mm(SIDE) } } },
    { kind: 'text', id: 'title', content: '{titleText}', ...display, fontSize: pt(58),
      lineHeight: 0.96, placement: { ...at('#kicker', 'below', mm(0), mm(4.5)),
        size: { width: mm(MAIN) } } },
    { kind: 'text', id: 'lead', content: '{attr.lead}', ...display, italic: true,
      fontSize: pt(14), lineHeight: 1.3, placement: { ...at('#title', 'below', mm(0), mm(5)),
        size: { width: mm(MAIN) } } },
    { kind: 'text', id: 'legend', content: '{attr.map}', fontFamily: TEXT, fontSize: pt(7.5),
      lineHeight: 1.4, color: col('muted'), align: 'left', overflow: 'wrap',
      placement: { ...at('#lead', 'align-top', mm(-HANG), pt(2)),
        size: { width: mm(SIDE - 6) } } },
    { kind: 'image', id: 'map', resourceId: 'situacion', // across the channel and the column
      placement: { ...at('container', 'top-left', mm(0), mm(MAP.y)),
        size: { width: mm(MAP.w) } } },
  ] } };

span: 'page'にすると、章扉のコンテナーは欄を含む版面全体になります(幅と詳細デザイン)。キッカーと題は57 mm内側、本文の段の左端に置き、平面図は欄と段にまたがります。これがないとコンテナーは本文の段になり、すべての要素が57 mm右へずれて、題、リード文、図がページの右端からはみ出します。デザインは図の下端まで高さを確保しますが、その位置は2本のグリッド線の間に落ちます。minHeightを次のグリッド線まで切り上げておくので、第1節の罫と本文の間隔は、以降のどの節の罫とも同じになります。キッカー、リード文、地図の凡例は# Competition briefの行の属性です。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 045 · Side heads, hanging numbers and run-in heads ═══════
// https://postext.dev/en/cookbook/side-heads-hanging-numbers
// Code: MIT · Text: original (CC BY 4.0) · Drawings: made in code (MIT)
// Fonts: Mona Sans, Noto Serif Display, DM Mono (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, defaultResourceTypes,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'side-heads-hanging-numbers';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // a Swiss municipal report: black, white and one signal red
  ink: '#17171a', // text and rules
  signal: '#d42a1f', // section numbers, run-in heads, the plot on the plans (5.1:1)
  tint: '#f9dcd7', // the plot's ground on the plans
  sea: '#d8e2e8', // water on the plans
  stone: '#cacad0', // built ground on the plans
  rule: '#c3c3ca', // hairlines under the running head and in tables
  muted: '#5e5e67', // running heads, legends, the colophon (6.4:1)
  paper: '#ffffff',
};
// Every colour is linked to its palette entry by id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// Defaults this config does not restate link to 'main-color', so it points at the accent.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.signal })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, DISPLAY, LABEL] = ['Mona Sans', 'Noto Serif Display', 'DM Mono'];
const TRIM = { width: 210, height: 297 }; // mm: A4, like every document of the competition
const [TOP, LEFT, RIGHT] = [26, 16, 16]; // mm; not mirrored: the brief prints one-sided
const LEAD = 14; // pt: the body leading, the pitch of the baseline grid
const LINES = 50; // grid lines in the text block
const PT = 25.4 / 72; // mm in a point
const GRID = LEAD * PT; // mm: one line of the grid
const CONTENT = TRIM.width - LEFT - RIGHT; // 178 mm
const [SIDE, GUTTER] = [50, 7]; // mm: the margin channel on the left, and the gap after it
const MAIN = CONTENT - SIDE - GUTTER; // 121 mm: the text column
const HANG = SIDE + GUTTER; // mm from the channel's left edge to the text's left edge
const at = (to, edge, x = mm(0), y = mm(0)) => ({ anchor: { to, edge }, offset: { x, y } });
// Kickers, running heads and folios: tracked capitals in the mono.
const LABEL_PT = 7.5;
const label = { fontFamily: LABEL, fontWeight: 500, fontSize: pt(LABEL_PT), lineHeight: 1.35,
  letterSpacing: pt(1.2), textTransform: 'uppercase', color: col('muted'), align: 'left' };

// #region channel: one text column, and on its left a channel for boxes and figures only
const layout = {
  layoutType: 'oneAndHalf',
  sideColumnPercent: (SIDE / CONTENT) * 100, // 50 of the 178 mm between the margins

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#罫を本文の段だけに引く

罫を番号ではなく見出し自身の箱に固定すると、罫は本文の左端から段の右端まで走り、欄には番号と題だけが残ります。

-        color: col('ink'), placement: { ...at('#number', 'right-of', mm(2), RULE_Y),
+        color: col('ink'), placement: { ...at('container', 'top-left', mm(0), RULE_Y),

よくあるつまずき

つまずき

サイド段の囲みは、囲みを開く位置の次のブロックと同じ高さから始まる

postext 1.4.1では、span: 'side'の囲みは、囲みを開く位置で本文が達した高さの次のグリッド行から、すでにある囲みがあればその下に、サイド段に置かれます。注釈は説明する段落の直前で開いてください。段落のあとで開くと、注釈は次の段落の横から始まります。段の末尾を越える囲みは、上の囲みが許す範囲で、下端が段の末尾にそろうまで上にずれます。それでも収まらない囲みは、次のページのサイド段まで待ちます。 欄外の注 →

つまずき

'top'のフロートは参照ページの先頭を許さない限り次のページに置かれる

既定では、フロートが自分の参照より上に置かれることはありません。そのため、Nページで参照したページ幅の'top'フロートはN+1ページの頭に置かれます。リソースまたはその種類のdefaultPlacementにplacement.citingPage: trueを設定すると(本全体ならlayout.floatsAtCitingPage、postext 1.25から)、layout.maxTopFraction以内に収まり参照行がそのページに残る場合は代わりにNページの先頭に置かれ、参照より前の本文はその下に送られます。章の最初のページと強制改ページの後のページの先頭には置かれません。その場合は次のページに置かれ、'auto'または'bottom'なら参照したページの下端に入れられます。 図の配置 →

Sandboxの検査 · headingAdvancedWithoutTitleText

見出しのタイトルを参照していません

原因. 詳細デザインに{titleText}を印字する要素がないため、見出し自体の文言が表示されません。

対処. 見出しを意図的に非表示にする場合を除き、{titleText}を含むテキスト要素を追加してください。 ドキュメント →

  • サイドの図は参照されたページで欄の頭を占め、その後に囲みのブロックで置いた欄外見出しは図の下、つまり自分の節の始まりより下に積まれます。第2節が敷地の平面図を参照しているように、サイドの図はそのページの節見出しの後で参照してください。
  • postext 1.28から、インラインの埋め込み(position: 'here')もcaptionSideを受け付けます。日程表のキャプションは5ページの欄に立ち、3ページの所要室の表と同じになります。キャプションには、表の横の欄が空いていることが必要です。そこに欄外見出しや欄の図がすでにあると、キャプションは表の下に残ります。

クレジット

レシピ
Ignacio Ferro
本文
書き下ろしの文章, CC BY 4.0
フォント
Mona Sans (SIL OFL 1.1) · Noto Serif Display (SIL OFL 1.1) · DM Mono (SIL OFL 1.1)
Sandbox