かんたんな説明
学会向けの短い研究論文を2段組みで組みます。著者は文献ごとにコードを書き、Postextは引用に角括弧の番号を振り、節を番号とページで参照し、最後に番号付きの文献一覧を印刷します。
できあがり
文書工学の小さなワークショップに出す2ページの論文を、IEEEの会議録と同じ組み方で組みます。USレター判、幅3.5インチの2段組み、10ptのTimes系の書体、I、II、IIIと番号を振った中央そろえの大文字の節見出しです。題、3つの著者ブロック、要旨、キーワードは、ワークショップの青で塗った淡い帯の下で2段にまたがって組みます。この青がページで唯一の色です。著者はBibTeXのキーで引用し、Postextは文献を最初に引用された順に[1]と番号を振り、連続する3つの文献を[2]–[4]にまとめ、名前が文の一部になるときは「Knuth and Plass [1]」と書き、最後の番号付き文献一覧を8ptで作ります。節への参照は「Section IV, on p. 2」と印刷され、本文が動いても正しいまま保たれます。
このレシピが答える質問
- APA、IEEEなどの引用スタイルで、文献を引用し参考文献を作るには?
- 節とそのページを参照し、本が変わっても両方を正しく保つには?
手短な答え
// [@key] prints [1] in order of first citation, @key in the sentence "Knuth and Plass [1]".
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
// The bundled IEEE style lists [2], [3], [4]; the IEEE editorial guide writes [2]–[4].
// One attribute on the CSL <citation> element makes citeproc-js join the run.
const ieee = STYLES.ieee.replace('<citation>', '<citation collapse="citation-number">');
const citations = {
style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
link: true,
bibliography: {
fontSize: em(0.8), lineHeight: pt(9.4), // 8 pt on 9.4 pt, two sizes under the text
labelWidth: mm(6), // the [n] column: wide enough for [10], the turnovers align after it
entrySpacing: pt(1.2),
doi: 'text', // printed, not linked: the PDF stays black
},
};
材料
- 種類
- STIX Two Text, Schibsted Grotesk (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 範囲をまとめるIEEEスタイル
コードは前に掲げた手短な答えです。一度登録すれば、postext-citeprocがすべての[@key]をciteproc-jsとIEEEのCSLスタイルで整形し、文献に最初に引用された順で番号を振ります。エンジンに同梱のスタイルファイルは、連続する3つの文献を[2]、[3]、[4]と並べますが、IEEEの編集ガイドは[2]–[4]とまとめます。スタイルの<citation>要素にcollapse="citation-number"を加え、その結果をcustomStyleとして渡すと、citeproc-jsがまとめてくれます。labelWidthは一覧の番号に専用の列を与えるので、項目の2行目は角括弧の下ではなく最初の語の下から始まります。
#2 · 2段にまたがる表題ブロック
const text = (id, content, size, extra) => ({ kind: 'text', id, content, fontFamily: SERIF,
fontSize: pt(size), color: col('ink'), align: 'center', overflow: 'wrap', ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
...(width && { size: { width: mm(width), height: 'auto' } }) });
const AUTHOR_W = MEASURE / 3;
const titleBlock = {
enabled: true,
minHeight: mm(64), // venue line, two lines of title and five of author block
slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('tint') }, // from the trim's top
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: 'fill', height: mm(TOP + 66) } } },
text('venue', '{attr.venue}', 7.5, { fontFamily: SANS, fontWeight: 600, color: col('accent'),
letterSpacing: pt(1.2), textTransform: 'uppercase',
placement: at('container', 'top-left', 0, 0, MEASURE) }),
{ kind: 'rule', id: 'venue-rule', thickness: pt(0.5), color: col('rule'),
placement: at('#venue', 'below', 0, 2, MEASURE) },
text('title', '{titleText}', 23, { lineHeight: 1.1, placement: at('#venue', 'below', 0, 7,
MEASURE) }),
...['a1', 'a2', 'a3'].map((id, i) => text(id, `{attr.${id}}`, 9.5, { lineHeight: 1.25,
placement: at('#title', 'below', i * AUTHOR_W, 6, AUTHOR_W) })),
] },
};
題は文書でただひとつのレベル1見出しで、スタイルはpaperです。このスタイルはページ幅にまたがり、見出しをデザインから描きます。会議名の行、題、行長の3分の1の幅の3つの著者ブロックで、どれも見出しの属性から取り、属性中の\nで改行します。帯は仕上がりに固定した箱なので、紙の上端まで届きます。
#3 · 太字の要旨とキーワード
const calloutStyles = [{ id: 'abstract', span: 'page', backgroundEnabled: false,
border: { enabled: false }, stripe: { enabled: true, side: 'top', width: pt(0.5),
color: col('rule') },
padding: { top: mm(3), right: mm(14), bottom: mm(1), left: mm(14) },
marginTop: pt(0), marginBottom: pt(LEAD),
body: { fontSize: pt(9), lineHeight: pt(11), fontWeight: 700, firstLineIndent: pt(0),
textAlign: 'justify', paragraphSpacing: true } }];
ページ幅にまたがる囲みに要旨とキーワードを入れます。本文はIEEEの組み方どおり9ptの太字で、テキスト中の***Abstract*—**がイタリックのラベルとエムダッシュを作ります。上の細罫は囲みのストライプで、内側余白が行長を約100字に狭めます。
#4 · 番号付きの節とその参照
const levels = [
{ level: 1, breakBefore: { enabled: true, parity: 'any' } }, // any page: no forced recto
{ level: 2, numberingTemplate: '{2:I}.', numberSeparator: ' ', fontSize: pt(9),
lineHeight: pt(LEAD), fontWeight: 400, letterSpacing: em(0.06), textTransform: 'uppercase',
marginTop: pt(LEAD), marginBottom: pt(0) }, // a line above, none below: at a column's head
// the margin above drops and the text still starts on the next grid line
];
const headingStyles = [
{ id: 'paper', numbered: false, span: 'page', advancedDesign: titleBlock },
{ id: 'back', numbered: false }, // Acknowledgment and References: no number
];
const crossRefs = { section: t({ en: 'Section {n}', es: 'sección {n}' }) };
{2:I}.で節にI.、II.、III.と番号を振ります。参照では番号の後のピリオドを省くので、:ref{id="sec:results"}はcrossRefsのテンプレートから「Section IV」となり、:ref{id="sec:results" style=page}は「p. 2」となります。どちらも組み上がったページから求めるので、段落が加わったり節が移ったりしても本文に追従します。謝辞(Acknowledgment)と文献(References)の見出しはbackスタイルを使い、番号を付けません。
const palette = {
ink: '#16181d', accent: '#1d4a7a', tint: '#e9eef5', rule: '#aeb6c2', muted: '#5a606b',
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
レシピの全体
// ═══ Postext Cookbook · Nº 088 · A two-column conference paper in IEEE style ═══════
// https://postext.dev/en/cookbook/ieee-conference-paper
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: STIX Two Text, Schibsted Grotesk (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'ieee-conference-paper';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: black type on white, with one blue for the workshop's own marks
const palette = {
ink: '#16181d', accent: '#1d4a7a', tint: '#e9eef5', rule: '#aeb6c2', muted: '#5a606b',
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS] = ['STIX Two Text', 'Schibsted Grotesk'];
// The IEEE conference template in mm: US letter, 0.75 in head, 1 in foot, 0.625 in sides,
// two columns of 3.5 in with 0.25 in between.
const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 19, 25.4, 15.9, 6.35];
const MEASURE = TRIM_W - 2 * SIDE;
const LEAD = 12; // pt: 10 pt type on 12 pt, as the template sets it
// #region answer: IEEE numbers, collapsed ranges and a references list with a label column
// [@key] prints [1] in order of first citation, @key in the sentence "Knuth and Plass [1]".
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
// The bundled IEEE style lists [2], [3], [4]; the IEEE editorial guide writes [2]–[4].
// One attribute on the CSL <citation> element makes citeproc-js join the run.
const ieee = STYLES.ieee.replace('<citation>', '<citation collapse="citation-number">');
const citations = {
style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
link: true,
bibliography: {
fontSize: em(0.8), lineHeight: pt(9.4), // 8 pt on 9.4 pt, two sizes under the text
labelWidth: mm(6), // the [n] column: wide enough for [10], the turnovers align after it
entrySpacing: pt(1.2),
doi: 'text', // printed, not linked: the PDF stays black
},
};
// #endregion
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#同梱のスタイルをそのまま使う
この編集をしなければ、連続する3つの文献は1つずつ印刷されます。こちらを好む論文誌もあります。
- style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
+ style: 'ieee',#範囲を1組の角かっこの中に書く
番号式のスタイルには[2–4]と印刷するものもあります。bracketsマーカーは番号を自分で書き、連続する番号をまとめます。
- style: 'custom', customStyle: ieee, // or style: 'ieee' for the file as it ships
+ style: 'ieee', marker: 'brackets', collapseRanges: true,よくあるつまずき
- 最終ページの2つの段の終わりがそろわないときは、段を切るはずの位置に何があるかを見てください。エンジンは節見出しを本文から離して段の下端に残すことはせず、その場合は段の切れ目のほうをあきらめます。最後のほうの節で1文増やすか減らすと、切れ目は見出しの先へ移ります。
{\TeX}のようなBibTeXのコマンドは展開されません。The {TeX}bookと書いてください。波括弧によって大文字がそのまま保たれます。
クレジット
- 本文
- 書き下ろしの文章, CC BY 4.0
- フォント
- STIX Two Text (SIL OFL 1.1) · Schibsted Grotesk (SIL OFL 1.1)


