かんたんな説明
街路樹と夏の暑さを扱った、科学の学会用の大きなポスターです。とても大きな1ページの上に、文章やグラフの枠を段に分けて並べる方法を示します。
できあがり
街路樹と歩道の暑さについての架空の研究を、600 × 800 mmの1ページの学会ポスターに組みます。緑の帯には学会名、110 ptのBitterの題、所属記号付きの著者名、地理学部(School of Geography)のマークが入ります。2段組みの要旨の下に、:::columnsグループを1つ置いて本文の2段をまたがせ、6つのパネルを3段に並べます。パネルはそれぞれが囲みで、6 ptの帯の下に置かれます。中央の段は150 ptのオレンジ色の−4.2 °Cで始まり、街区と時刻ごとの気温を示すヒートマップが色見本の凡例とともに続き、舗装の棒グラフが来ます。下の余白には、キーワードのチップを並べた色付きの帯を置きます。同じファイルでスペイン語版も組め、CodePenのサンプルではページを1,701 × 2,268 pxのPNGとして書き出せます。
このレシピが答える質問
- ページの途中に、2段をまたぐ囲み(3つ並びの「数字で見る」欄など)を置くには?
- 囲みの中を2段にするには(本文の段と図の段を並べる)?
- 本文、キャプション、表の注に色見本(凡例の色)を加えるには?
手短な答え
// The body text runs in two columns and the panels in three: a :::columns group in the
// text, and span="page" lays it across both body columns, the gutter apart.
// :::columns{count=3 breaks="3,4" span="page" marginBottom="0.75em"}
// ← panel 3 opens column 2, panel 4 column 3
// :::callout{type="panel" title="Introduction"} ← each panel is a box in the group
// …
// ::: ← closes the panel; then the other panels
// ::: ← closes the columns group
// marginBottom sets the space under the group: without it the group is followed by a
// line of the summary's paragraph spacing, 38 pt.
// A box in a group takes the width of its column. Its one device is a 6 pt stripe along
// the top.
const panel = { id: 'panel', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(6), color: col('canopy') },
padding: { top: mm(5), right: pt(0), bottom: pt(0), left: pt(0) },
titleStyle: { fontFamily: 'Saira Condensed', fontSize: pt(40), fontWeight: 700,
textTransform: 'uppercase', letterSpacing: pt(4), color: col('canopy'), gap: mm(4) },
body: { fontSize: pt(22), lineHeight: pt(30) }, // the rest follows bodyText
marginTop: mm(18) };
const results = { ...panel, id: 'results', // the finding: the same panel, striped in heat
stripe: { ...panel.stripe, color: col('heat') },
titleStyle: { ...panel.titleStyle, color: col('heat') } };
材料
- 機能
- 囲みの中や本文中の段組み段抜きの囲みデザインした章扉見出しの属性デザイン要素の基準位置ページデザインの画像色見本インラインのチップセマンティックカラーパレット囲みその場に置く図段落スタイル仕上がりサイズキャンバス上のページ番号付きキャプション出典とクレジットフロートする囲みベースライングリッド段抜きの章見出し帯
- 種類
- Rethink Sans, Bitter, Saira Condensed (SIL OFL 1.1)
- 素材
- The plan of the street, the heat map, the bar chart and the School of Geography's mark, drawn in code from synthetic data in the poster's palette (Ignacio Ferro, CC BY 4.0)
作り方
#1 · 72 dpiでレイアウトする
const SHEET = { width: 600, height: 800, margin: 25 }; // mm: a portrait board, 25 mm all round
const GAP = 12; // mm between the two body columns and between the three panel columns
// The summary's leading is the page's baseline grid: 56 lines fill the 750 mm between the
// margins, so a box floated to the foot of the page ends on the bottom margin.
const LEAD = (((SHEET.height - 2 * SHEET.margin) / 25.4) * 72) / 56; // 37.96 pt
const page = { width: mm(SHEET.width), height: mm(SHEET.height),
// At 72 dpi a point is a pixel: the page is 1,701 × 2,268 px. The default 300 dpi would give
// 7,087 × 9,449 px (268 MB of canvas) for the same line breaks.
dpi: 72, backgroundColor: col('paper'),
margins: { top: mm(SHEET.margin), bottom: mm(SHEET.margin), left: mm(SHEET.margin),
right: mm(SHEET.margin) } }; // one sheet, nothing to mirror
既定の300 dpiでも行の分割は72 dpiのときと同じですが、ページは7,087 × 9,449 pxになり、描画すると268 MBのピクセルになります(ページサイズのプリセット)。72 dpiでは1ポイントが1ピクセルです。ビューアーはrenderPageToCanvasとscaleでサムネイルを描画し、renderPageは学会のオンラインギャラリーが求める1,701 × 2,268 pxのPNGを出力します(ページをビットマップに描画する)。行送りは天地の余白のあいだの750 mmを56行に割るので、ページの地へフロートとして配置したキーワードの帯は、ちょうど下の余白の線で終わります。きりのよい38 ptにすると55行しか入らず、最終行は余白まで12.7 mm足りません。するとキーワードの帯はパネルの下に収まらなくなり、2ページ目に移ります。
#2 · 題の帯を見出しから描く
const BAND = 158; // mm from the top edge to the foot of the green field
const type = (id, content, family, size, look, placement) => ({ kind: 'text', id, content,
fontFamily: family, fontSize: pt(size), color: col('paper'), align: 'left',
overflow: 'wrap', lineHeight: 1.2,
...look, placement });
const band = { enabled: true,
// The field ends 133 mm under the top margin; eleven grid lines (147 mm) start the summary
// 14 mm below it.
minHeight: pt(11 * LEAD),
slot: { elements: [
{ kind: 'box', id: 'field', style: { backgroundColor: col('canopy') },
placement: { ...at('page', 'top-left'), size: { width: 'fill', height: mm(BAND) } } },
type('meeting', '{attr.meeting}', 'Saira Condensed', 22, { fontWeight: 600,
textTransform: 'uppercase', letterSpacing: pt(3.5), color: col('tint') },
{ ...at('page', 'top-left', SHEET.margin, 18), size: { width: mm(420) } }),
type('title', '{titleText}', 'Bitter', 110, { fontWeight: 800, lineHeight: 1 },
{ ...at('#meeting', 'below', 0, 7), size: { width: mm(380) } }),
type('authors', '{attr.authors}', 'Rethink Sans', 30, { fontWeight: 700 },
{ ...at('#title', 'below', 0, 7), size: { width: 'fill' } }),
// The affiliation marks are the characters ¹ ² ³, typed in the heading's attributes.
type('affiliations', '{attr.affiliations}', 'Rethink Sans', 21, { color: col('tint') },
{ ...at('#authors', 'below', 0, 2), size: { width: 'fill' } }),
type('number', '{attr.poster}', 'Saira Condensed', 30, { fontWeight: 700,
color: col('canopy'), box: { backgroundColor: col('paper'),
padding: { top: mm(1.5), right: mm(4), bottom: mm(1), left: mm(4) } } },
at('page', 'top-right', -SHEET.margin, 15)),
// The School of Geography's mark, drawn in code.
{ kind: 'image', id: 'mark', resourceId: 'mark',
placement: { ...at('page', 'top-right', -SHEET.margin, 38), size: { width: mm(92) } } },
] } };
H1は学会名、ポスター番号、著者名、所属を属性として持ち、そのデザインがこれらを、ページに固定した深さ158 mmの緑のボックスの上に組みます(幅と詳細デザイン)。ボックスは天の余白から133 mm下で終わります。minHeightがないと要旨は緑の0.9 mm下から始まりますが、グリッド線11本分のminHeightを指定すると14 mm空きます。所属記号には文字¹ ² ³を使います。Latin-1の範囲にある上付き数字はこの3つだけです。
#3 · ページ幅のグループにパネルを並べる
// The body text runs in two columns and the panels in three: a :::columns group in the
// text, and span="page" lays it across both body columns, the gutter apart.
// :::columns{count=3 breaks="3,4" span="page" marginBottom="0.75em"}
// ← panel 3 opens column 2, panel 4 column 3
// :::callout{type="panel" title="Introduction"} ← each panel is a box in the group
// …
// ::: ← closes the panel; then the other panels
// ::: ← closes the columns group
// marginBottom sets the space under the group: without it the group is followed by a
// line of the summary's paragraph spacing, 38 pt.
// A box in a group takes the width of its column. Its one device is a 6 pt stripe along
// the top.
const panel = { id: 'panel', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(6), color: col('canopy') },
padding: { top: mm(5), right: pt(0), bottom: pt(0), left: pt(0) },
titleStyle: { fontFamily: 'Saira Condensed', fontSize: pt(40), fontWeight: 700,
textTransform: 'uppercase', letterSpacing: pt(4), color: col('canopy'), gap: mm(4) },
body: { fontSize: pt(22), lineHeight: pt(30) }, // the rest follows bodyText
marginTop: mm(18) };
const results = { ...panel, id: 'results', // the finding: the same panel, striped in heat
stripe: { ...panel.stripe, color: col('heat') },
titleStyle: { ...panel.titleStyle, color: col('heat') } };
本文は2段、パネルは3段なので、グリッドは本文に直接書いた:::columns{count=3}グループにし、span="page"で要旨の下で本文の両方の段にまたがらせます。グループの段はページの段間で区切られます(:::columns)。何も指定しないと、本文中のグループの下には段落間のアキ1行分(ここでは38 pt)が入り、キーワードの帯が2ページ目へ移ってしまいます。開始行にmarginBottom="0.75em"を書くと、これがその1行に代わり(postext 1.28)、帯はページの地に収まります。各パネルはグループの中の囲みです。それぞれが独自のスタイルを使い、段の幅175 mmと、上のパネルからのmarginTop 18 mmを取ります(:::calloutコンテナー)。breaks="3,4"は3つ目のパネルResultsを中央の段の頭へ、4つ目のConclusionsを最後の段の頭へ送ります。これがないとグループは段の高さをそろえようとし、積み重ねの3分の1ごとの位置に最も近いパネルで切ります。この原稿では切れ目が同じ2つのパネルに来ますが、原稿が変わってもこの属性が切れ目をそこに保ちます。
#4 · 図をパネルの中にとどめる
// "Figure 1", not "Figure 1.1": the poster has no chapters.
const figureType = { ...defaultResourceTypes(LANG)[0], numberingTemplate: '{n}' };
const resourceTypes = [figureType];
const figure = (id, [width, height], caption, altText) => ({ id, typeId: figureType.id,
kind: 'svg', svg: { fileId: `${id}.svg`, width: width * 10, height: height * 10 },
placement: { position: 'here' }, // stays in its panel, where ::resource puts it; else floats
caption, altText, note: t({ en: 'Synthetic data, generated for this poster.',
es: 'Datos sintéticos, generados para este póster.' }), createdAt: 0, updatedAt: 0 });
'here'に配置した図は、::resourceを書いたパネルの中にとどまります。既定の配置では3つの図がパネルを離れ、ポスターは2ページ目にはみ出します。numberingTemplate: '{n}'で図番号は1、2、3になります。既定の{h1}.{n}では、題がH1なのでFigure 1.1と印刷されます(リソースの種類)。各キャプションの下の注で、データが合成データであることを示します。
#5 · ヒートマップの色を凡例と共有する
const palette = {
ink: '#102a2c', // text: a green-black
paper: '#f7faf7', // the sheet, and type on the band
canopy: '#2e7d4f', // the band, the stripes and titles of five panels, the tree crowns
tint: '#e6f2ea', // the keyword strip, the park on the plan, lines of type on the band
rule: '#bcd2c4', // buildings on the plan, the chart's grid
muted: '#587068', // the notes under the figures, the axis titles inside them
// The key of Figure 2, the air against the street mean at the same hour. The heat map's
// cells and the :swatch runs of its key read the same four entries.
cool: '#3b82c4', // −1.5 °C or less
mist: '#a9c9e6', // −1.5 to 0 °C
blush: '#f2b492', // 0 to +1.5 °C
heat: '#d9572b', // +1.5 °C or more; also −4.2 °C, the Results panel, the loggers, the sun
};
// Every colour is linked to its palette entry by id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [ // defaults link to 'main-color': point it at the canopy green
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'canopy (defaults)', value: { hex: palette.canopy, model: 'hex' } },
];
ヒートマップのセルと凡例の4つの:swatch{color="…"}は同じパレットの項目を指しているので、coolの値を変えると地図と凡例が一緒に塗り直されます(インライン書式)。凡例はResultsパネルの中に置いた2つ目の:::columnsグループで、1段に2項目ずつ入ります。
#6 · 大きな数字を段落スタイルで組む
const paragraphStyles = [
// Paragraph styles apply inside boxes. The figure is written **bold**: that sets it in
// Bitter 700 and in the style's boldColor.
// containerSpacing 'add': the group ends on the style's own space, with no line of
// paragraph spacing under it. −4.2 °C sits on the line that explains it, and a :::space
// sets the gap under the references.
{ id: 'stat', fontFamily: 'Bitter', fontSize: pt(150), lineHeight: pt(130),
boldColor: col('heat'), containerSpacing: 'add' },
{ id: 'refs', fontSize: pt(19), lineHeight: pt(26), hangingIndent: mm(9), spaceBetween: pt(8),
containerSpacing: 'add' },
{ id: 'key', fontSize: pt(19), lineHeight: pt(28) }, // the key of Figure 2
];
const chipStyles = [{ id: 'keyword', background: col('paper'), borderColor: col('canopy'),
borderWidth: pt(1.5), borderRadius: em(1), paddingX: em(0.55), paddingY: em(0.14),
color: col('canopy'), bold: true, gap: em(0.35) }];
const strip = { id: 'strip', background: col('tint'), // one device: a tint
padding: { top: mm(4), right: mm(8), bottom: mm(4), left: mm(8) }, columnGap: mm(GAP),
body: { fontSize: pt(18), lineHeight: pt(24) } };
段落スタイルは囲みの中でも効くので、−4.2 °CはResultsパネルの中に置いた:::paragraphs{style="stat"}のブロックにし、150 ptのBitterで組みます(段落スタイル)。数字は太字で書くので、Bitter 700で、スタイルのboldColorであるパネルのオレンジ色で印刷されます。もう1つのスタイルで、文献一覧に9 mmのぶら下げインデントを付けます。キーワードの帯はplacement="bottom"の色付きの囲みで、グリッドの下、ページの地へフロートとして配置します。
レシピの全体
// ═══ Postext Cookbook · Nº 059 · Research poster on one big page ══════════════════
// https://postext.dev/en/cookbook/research-poster
// Code: MIT · Text and data: original, synthetic (CC BY 4.0) · Figures: generated in code
// Fonts: Rethink Sans, Bitter, Saira Condensed (SIL OFL 1.1) · Needs postext ≥ 1.28.0
import {
buildDocumentWithFonts, renderPage, renderPageToCanvas, registerResourceImage,
defaultResourceTypes, inlineSvgFonts,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'research-poster';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: six colours for the poster, four for the heat map's key
const palette = {
ink: '#102a2c', // text: a green-black
paper: '#f7faf7', // the sheet, and type on the band
canopy: '#2e7d4f', // the band, the stripes and titles of five panels, the tree crowns
tint: '#e6f2ea', // the keyword strip, the park on the plan, lines of type on the band
rule: '#bcd2c4', // buildings on the plan, the chart's grid
muted: '#587068', // the notes under the figures, the axis titles inside them
// The key of Figure 2, the air against the street mean at the same hour. The heat map's
// cells and the :swatch runs of its key read the same four entries.
cool: '#3b82c4', // −1.5 °C or less
mist: '#a9c9e6', // −1.5 to 0 °C
blush: '#f2b492', // 0 to +1.5 °C
heat: '#d9572b', // +1.5 °C or more; also −4.2 °C, the Results panel, the loggers, the sun
};
// Every colour is linked to its palette entry by id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [ // defaults link to 'main-color': point it at the canopy green
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'canopy (defaults)', value: { hex: palette.canopy, model: 'hex' } },
];
// #endregion
// #region sheet: one 600 × 800 mm page, laid out at 72 dpi
const SHEET = { width: 600, height: 800, margin: 25 }; // mm: a portrait board, 25 mm all round
const GAP = 12; // mm between the two body columns and between the three panel columns
// The summary's leading is the page's baseline grid: 56 lines fill the 750 mm between the
// margins, so a box floated to the foot of the page ends on the bottom margin.
const LEAD = (((SHEET.height - 2 * SHEET.margin) / 25.4) * 72) / 56; // 37.96 pt
const page = { width: mm(SHEET.width), height: mm(SHEET.height),
// At 72 dpi a point is a pixel: the page is 1,701 × 2,268 px. The default 300 dpi would give
// 7,087 × 9,449 px (268 MB of canvas) for the same line breaks.
dpi: 72, backgroundColor: col('paper'),
margins: { top: mm(SHEET.margin), bottom: mm(SHEET.margin), left: mm(SHEET.margin),
right: mm(SHEET.margin) } }; // one sheet, nothing to mirror
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#e-posterを150 dpiで書き出す
大きなファイルを求める学会には、改行位置が同じ3,543 × 4,724 pxのPNGを渡せます。
- dpi: 72, backgroundColor: col('paper'),
+ dpi: 150, backgroundColor: col('paper'),よくあるつまずき
- Rethink Sansは、11(3)の号数のように括弧で囲んだ1桁の数字を、Canvas上で丸数字として描きます。そのため文献一覧には巻とページだけを書いています。
- 文書の最後に来るページ幅の囲みは、その下に本文2行分の空きが残らないと新しいページへ移ります。そこでキーワードの帯は
placement="bottom"でフロートとして配置し、グリッドの下に残った50 mmの中で、下の余白の線上に置きます。 - スタイル
statとrefsにcontainerSpacing: 'add'を指定すると、その:::paragraphsグループはスタイル自身のアキで終わるので、−4.2 °Cがそれを説明する行のすぐ上に収まります。ポスターのほかのグループは文書の規則に従います(postext 1.28から。それ以前はbodyText.paragraphContainerSpacingで文書全体に指定するしかありませんでした)。最後の文献の下では、そのアキはスタイルのspaceBetweenの2.8 mmです。そこで謝辞の前に:::space{lines=0.75}を置くと10.8 mm空き、パネル内のほかの段落のあいだの10.6 mmに近くなります。これを指定せず、文書の'collapse'のままにすると、グループの後にパネルの段落間のアキ1行分が入ります。謝辞に:::spaceは要らなくなりますが、−4.2 °Cの下に1行増えるため、キーワードの帯が2ページ目へ移ります。
クレジット
- 本文
- 書き下ろしの文章, CC BY 4.0
- 画像
- The plan of the street, the heat map, the bar chart and the School of Geography's mark, drawn in code from synthetic data in the poster's palette · Ignacio Ferro · CC BY 4.0
- フォント
- Rethink Sans (SIL OFL 1.1) · Bitter (SIL OFL 1.1) · Saira Condensed (SIL OFL 1.1)


