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

レシピ集 · 第7章 · 図と画像

データ図をページ上部に渡した物理学レター

GW150914発見のレターを2段組みで組み直します。1ページ目にオープンデータから描き直した信号、[1]形式の番号付き引用、番号付きの数式と表I。

このページの内容

1ページ(全5ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり215.9 × 279.4 mm
  • 2段, 段間7 mm
  • Gelasio 9.3/12.4
  • Albert Sans
  • 5ページ
  • レベル
  • Postext 1.65.0
  • 組版時間209 ms
  • コード189行

かんたんな説明

初めて重力波をとらえたと発表した2016年のレターを、抄録してUSレター判で組み直したものです。2台の検出器の信号は公開データから描き直して1ページ目に渡し、参考文献は角括弧の番号で示します。

できあがり

初めて重力波をとらえたと発表したレター『Observation of Gravitational Waves from a Binary Black Hole Merger』(Abbott et al., 2016)を抄録し、USレター判の2段組みで組み直した5ページです。1ページ目は証拠から始まります。HanfordとLivingstonで記録されたひずみを、重力波オープンサイエンスセンター(GWOSC)のオープンデータのファイルから描き直し、表題の下で2段にまたがって置きます。その下に共同研究の著者表記と脚注、段をまたぐ抄録、本文が続き、引用はAPSの学術誌と同じく[1,2]や[25–27]と番号で示します。チャープ質量は式(1)です。表Iは非対称な誤差を上付きと下付きを重ねて表し、セルには数式として書きます。キャプションにもレターにある数式をそのまま組みます。自分のBibTeXとデータファイルに差し替えれば、同じスクリプトであなたのレターが組めます。

このレシピが答える質問

  • 物理学のレターを組むには(共同研究チームの著者表記、2段にまたがる要旨、上部に段抜きのデータ図)?
  • 図の位置を制御するには(ページの上端、2段をまたぐ、まさにこの位置、余白)?
  • 数式(インライン、ディスプレイ、方程式)を組み、PDFでもベクターのまま保つには?
  • arXivやPubMed Centralのオープンアクセス論文を、引用・図・ライセンス表記を保ったままPostextで組み直すには?

手短な答え

script.js · 32〜60行コード全体で見る
// [@key] numbers works by first citation. APS journals print [1,2] and [2–4] in one pair of
// brackets and list "A. Einstein, Sitzungsber. K. Preuss. Akad. Wiss. 1, 688 (1916).": no
// title, volume bold. No APS style is bundled: four edits turn the IEEE file into one.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const ARTICLE = '<group delimiter=" "><text variable="container-title"/><text '
  + 'variable="volume" font-weight="bold" suffix=","/><text variable="page"/><date '
  + 'variable="issued" prefix="(" suffix=")"><date-part name="year"/></date></group>';
const BOOK = '<group delimiter=" "><group delimiter=", "><choose><if type="chapter"><text '
  + 'variable="container-title" prefix="in " font-style="italic"/></if><else><text variable='
  + '"title" font-style="italic"/></else></choose><names variable="editor" prefix="edited by ">'
  + '<name and="text" initialize-with=". "/></names><text variable="collection-title"/><text '
  + 'variable="volume" prefix="Vol. "/></group><group prefix="(" suffix=")" delimiter=", ">'
  + '<text variable="publisher"/><text variable="publisher-place"/><date variable="issued">'
  + '<date-part name="year"/></date></group></group><text variable="page" prefix="pp. "/>';
const aps = STYLES.ieee
  .replace('<citation>', '<citation collapse="citation-number">') // [2–4], not [2], [3], [4]
  .replace(/<layout delimiter=", ">\s*<group prefix="\[" suffix="\]" delimiter=", ">/,
    '<layout prefix="[" suffix="]" delimiter=","><group delimiter=", ">') // [1,2]
  .replace('et-al-min="7"', 'et-al-min="11"') // ten authors are listed, as in the letter
  .replace(/<bibliography[\s\S]*<\/bibliography>/, '<bibliography second-field-align="flush">'
    + '<layout suffix="."><text variable="citation-number" prefix="[" suffix="]"/><text '
    + 'macro="author"/><choose><if type="manuscript"><text variable="note" prefix=" "/></if>'
    + `<else><group prefix=", " delimiter=", "><choose><if type="article-journal">${ARTICLE}`
    + `</if><else-if type="book chapter" match="any">${BOOK}</else-if><else><text variable=`
    + '"URL"/><text variable="note"/></else></choose></group></else></choose></layout>'
    + '</bibliography>');
const citations = { style: 'custom', customStyle: aps, link: true,
  bibliography: { fontSize: em(0.84), lineHeight: pt(9.5), entrySpacing: pt(0.4),
    labelWidth: mm(6.2) } }; // the [64] column: turnovers line up after the widest label

材料

種類
Gelasio, Albert Sans (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · IEEEスタイルから物理学の番号付き引用を作る

コードは上の手短な答えにあります。postext-citeprocにはAPSスタイルが同梱されておらず、同梱スタイルでいちばん近いのはieeeです。引用順の番号、角括弧、姓の前の頭文字が共通しています。STYLES.ieeeに4か所の文字列置換を加えると差が埋まります。collapse="citation-number"で連続番号をまとめ([25–27])、layoutに角括弧を1組だけ置いて*[1,2]と印刷し、et-al-minを11に上げて10人の著者名を省略せずに並べ、新しい<bibliography>ブロックでPhysical Reviewと同じく誌名、太字の巻、ページ、年を印刷します。たとえばPhys. Rev. Lett.* 74, 3515 (1995)です。43件の文献は独立した:::references{format=bibtex}ブロックに入れます。{{J. Aasi et al.}}のように二重の波括弧で囲んだ名前はそのまま印刷され、レターが自分たちの共同研究の長い著者リストを引くときの書き方になります。引用と参考文献を参照してください。

#2 · 表題の下で2段にまたがる図1

script.js · 64〜89行コード全体で見る
const text = (id, content, family, size, extra) => ({ kind: 'text', id, content, align: 'left',
  fontFamily: family, fontSize: pt(size), color: col('ink'), 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 caps = (size) => ({ fontWeight: 700, letterSpacing: pt(size * 0.2),
  textTransform: 'uppercase', color: col('accent') });
const letter = { id: 'letter', numbered: false, span: 'page', marginBottom: pt(0),
  advancedDesign: { enabled: true, minHeight: mm(21), slot: { elements: [
    text('kicker', '{attr.kicker}', SANS, 7.5, { ...caps(7.5),
      placement: at('container', 'top-left', 0, 2, MEASURE) }),
    text('title', '{titleText}', SANS, 23, { fontWeight: 700, lineHeight: 1.08,
      placement: at('#kicker', 'below', 0, 2.2, MEASURE) }),
  ] } } };
const box = { padding: { top: mm(2.6), right: mm(12), bottom: mm(2.4), left: mm(12) },
  background: col('tint'), marginTop: pt(0), marginBottom: pt(LEAD), span: 'page',
  body: { fontSize: pt(9.3), lineHeight: pt(12.6), firstLineIndent: pt(0) } };
// ::resource{id="fig1"} right under the title, placed { position: 'here', span: 'page' }:
// it spans both columns on page 1, where a float could only follow its citation.
const paragraphStyles = [
  { id: 'byline', fontFamily: SANS, fontSize: pt(10), lineHeight: pt(12.6), fontWeight: 600,
    textAlign: 'center', firstLineIndent: pt(0) },
  { id: 'dates', fontFamily: SANS, fontSize: pt(7.6), lineHeight: pt(12.6), textAlign: 'center',
    color: col('muted'), firstLineIndent: pt(0) },
  { id: 'colophon', fontFamily: SANS, fontSize: pt(7), lineHeight: pt(9.4), color: col('muted'),
    textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(LEAD) },
];

フロートは引用した行より上には置かれず、本文が図1を初めて引用するのは第II節なので、フロートのままでは1ページ目に届きません。そこでこのレターは図を直接置きます。::resource{id="fig1"}を表題のすぐあとに書き、配置を{ position: 'here', span: 'page' }とすると、その位置で2段にまたがって組まれ、段はその下に続きます。著者表記と抄録はそのあとのページ幅の囲みfrontに入り、その中の:::paragraphsブロックで著者表記を中央にそろえ、日付を小さく組みます。*et al.*のあとの脚注記号は注を1段目の下へ送ります。APSの学術誌が著者に関する注を置くのと同じ位置です。footnotes.numberFormat: 'lower-alpha'で脚注に文字の番号を振るので、参考文献の番号と取り違えることがありません。ブロック埋め込みと脚注を参照してください。

#3 · セルに数式が入る表I

script.js · 346〜354行コード全体で見る
// A cell sets $…$ in the line, at the table's size: the errors stack over and under the value.
const VALUES = [['Primary black hole mass', '$36^{+5}_{-4}\\,M_\\odot$'],
  ['Secondary black hole mass', '$29^{+4}_{-4}\\,M_\\odot$'],
  ['Final black hole mass', '$62^{+4}_{-4}\\,M_\\odot$'],
  ['Final black hole spin', '$0.67^{+0.05}_{-0.07}$'],
  ['Luminosity distance', '$410^{+160}_{-180}$ Mpc'],
  ['Source redshift $z$', '$0.09^{+0.03}_{-0.04}$']];
const table = { model: { columnWidths: [1.3, 1], rows: VALUES.map(([label, value]) =>
  [{ content: label, verticalAlign: 'middle' }, { content: value }]) } };

postext 1.19からは、セルも本文と同じように$…$を数式として組みます。各値は$36^{+5}_{-4}\,M_\odot$のようにTeXで書き、2つの誤差は数値の上と下に重なり、セルの行の高さに収まるよう縮められます。Markdownの^+5^~−4~では2つの誤差が横に並んでしまいます。キャプションと注にも同じ数式が使えます。図2は$R_S = 2GM/c^2$、図4は$5.1\sigma$と書き、MathJaxの字形で組まれます。本文の2つの書体にないギリシャ文字もこの字形にはあり、PDFではベクトルのパスとして残ります。リソースタイプは、キャプションではFIG. 1とTABLE I、本文ではFig. 1とTable Iと印刷します。captionPrefixと、表にはcounterFormat: 'upper-roman'を指定しています。数式を参照してください。

#4 · オープンデータから描いた図

script.js · 17〜22行コード全体で見る
const palette = { ink: '#171a21', accent: '#25578a', tint: '#eef2f6', rule: '#b7c0ca',
  muted: '#5a636e', paper: '#ffffff' };
const data = { hanford: '#cf5f24', livingston: palette.accent, purple: '#74519c' }; // figures
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' } }));

4つの図はすべてコードで描いています。データはGWOSCがこのレターとともに公開したファイルで、ライセンスはCC BY 4.0です。各曲線は8サンプルごとに1点を残し、図1の0.21秒で430点になります。各点は直前の点からの変化をbase-64の1文字で記録するので、5本の曲線がスクリプトの中で3 KB未満に収まります。残差の段は原論文と同じく、データから波形を引いたものです。どの図でもHanfordはオレンジ、Livingstonは青で、本文はページの墨色と青1色だけを使います。ラベルはMathJaxのサンセリフ(\textsf)のパスです。軸の指数や記号が本文の数式と同じ組み方になり、PDFでは線もラベルもすべてベクターのまま残ります。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 140 · A physics letter with a data figure across the top ═══
// https://postext.dev/en/cookbook/physics-letter-two-columns
// Code: MIT · Text: Abbott et al., PRL 116, 061102 (CC BY 3.0) · Data: GWOSC (CC BY 4.0)
// Fonts: Gelasio, Albert Sans (SIL OFL 1.1) · Needs postext ≥ 1.34.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, registerCitationEngine,
  defaultResourceTypes, initMathEngine, renderMath,
} 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 = 'physics-letter-two-columns';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink and one blue for the text; the detectors' colours for the data
const palette = { ink: '#171a21', accent: '#25578a', tint: '#eef2f6', rule: '#b7c0ca',
  muted: '#5a636e', paper: '#ffffff' };
const data = { hanford: '#cf5f24', livingston: palette.accent, purple: '#74519c' }; // figures
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] = ['Gelasio', 'Albert Sans'];
// mm: US Letter, head, foot and side margins, gutter; then the measure and one column
const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 21, 21, 16, 7];
const MEASURE = TRIM_W - 2 * SIDE;
const COLUMN = (MEASURE - GUTTER) / 2;
const [BODY, LEAD] = [9.3, 12.4]; // pt: a letter journal's density, two columns of 88 mm

// #region answer: physics citations [1] and [2–4], from the bundled IEEE style
// [@key] numbers works by first citation. APS journals print [1,2] and [2–4] in one pair of
// brackets and list "A. Einstein, Sitzungsber. K. Preuss. Akad. Wiss. 1, 688 (1916).": no
// title, volume bold. No APS style is bundled: four edits turn the IEEE file into one.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const ARTICLE = '<group delimiter=" "><text variable="container-title"/><text '
  + 'variable="volume" font-weight="bold" suffix=","/><text variable="page"/><date '
  + 'variable="issued" prefix="(" suffix=")"><date-part name="year"/></date></group>';
const BOOK = '<group delimiter=" "><group delimiter=", "><choose><if type="chapter"><text '
  + 'variable="container-title" prefix="in " font-style="italic"/></if><else><text variable='
  + '"title" font-style="italic"/></else></choose><names variable="editor" prefix="edited by ">'
  + '<name and="text" initialize-with=". "/></names><text variable="collection-title"/><text '
  + 'variable="volume" prefix="Vol. "/></group><group prefix="(" suffix=")" delimiter=", ">'
  + '<text variable="publisher"/><text variable="publisher-place"/><date variable="issued">'
  + '<date-part name="year"/></date></group></group><text variable="page" prefix="pp. "/>';
const aps = STYLES.ieee
  .replace('<citation>', '<citation collapse="citation-number">') // [2–4], not [2], [3], [4]
  .replace(/<layout delimiter=", ">\s*<group prefix="\[" suffix="\]" delimiter=", ">/,

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

アレンジ

#同梱のIEEEスタイルをそのまま使う

置換を外すと、本文は*[2], [3], [4]、文献一覧はA. Einstein, “title”, journal…*の形になります。

-const citations = { style: 'custom', customStyle: aps, link: true,
+const citations = { style: 'ieee', link: true,

#Natureのように上付き番号にする

Natureのスタイルは上付きの番号を使い、文献の表題も載せます。同梱されています。

-const citations = { style: 'custom', customStyle: aps, link: true,
+const citations = { style: 'nature', link: true,

#A4判で組む

仕上がり寸法を変えれば、版面、段、すべての図がそれに合わせて変わります。

-const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 21, 21, 16, 7];
+const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [210, 297, 22, 22, 15, 7];

よくあるつまずき

つまずき

数式には最初のビルドの前にawait initMathEngine()が必要

数式エンジンが動き出す前にレイアウトした数式は、灰色のプレースホルダーの箱になります。initMathEngineをほかのシンボルと一緒にhttps://esm.sh/postextから読み込み、最初のビルドの前にawaitしてください。数式のある文書をこれなしでビルドすると、コンソールに警告が1つ出ます。postext 1.5からは、MathJaxはinitMathEngineが取得する1つのモジュールとしてパッケージに含まれているので、通常のimportがCDNから使え、?bundleは必要ありません(1.4までは、すべてのシンボルをhttps://esm.sh/postext?bundleから読み込む必要がありました)。読み込むURLは1つだけにしてください。URLが2つあると、エンジンが2つ読み込まれます。 数式 →

  • postext 1.18までは、2段組みの流れの中でspan: 'page'を付けた'here'のリソースが1段の幅で組まれ、キャプションやセルの$はそのまま印刷されました。1.19以降を指定します。
  • キャプションやセルに文字として打ったギリシャ文字、⊙、≃は、画面ではシステムフォントに置き換わり、PDFでは欠落します。PDFには各書体のラテン文字のファイルしか埋め込まれないためです。$\sigma$や$M_\odot$のように数式として書き、図の中では描いて示します。
  • 数百人の著者リストはBibTeXファイルには向きません。学術誌に印刷されたとおりの名前を二重の波括弧で囲んで書きます。author={{B. Abbott et al.}}。
  • 論文とデータのライセンス表記は残します。このレシピでは脚注と奥付で削った部分を示し、各キャプションの注記でデータの出典と描き直した図で省いた部分を記しています。

クレジット

レシピ
Ignacio Ferro
本文
  • Text: B. P. Abbott et al. (LIGO Scientific Collaboration and Virgo Collaboration), “Observation of Gravitational Waves from a Binary Black Hole Merger”, Phys. Rev. Lett. 116, 061102 (2016), doi:10.1103/PhysRevLett.116.061102. Abridged from the published letter (Sections IV and VII, parts of Sections I, III, V and VI and most of the acknowledgments cut; sections and references renumbered); figures redrawn; figure captions shortened. Licence: CC BY 3.0, https://creativecommons.org/licenses/by/3.0/ · LIGO Scientific Collaboration and Virgo Collaboration · CC BY 3.0
  • Data for Figures 1, 2 and 4: the GW150914 data files released by the Gravitational Wave Open Science Center (gwosc.org), a service of the LIGO Scientific Collaboration, the Virgo Collaboration and KAGRA; redrawn in code · LIGO Scientific Collaboration and Virgo Collaboration, GWOSC · CC BY 4.0
フォント
Gelasio (SIL OFL 1.1) · Albert Sans (SIL OFL 1.1)
SandboxPDF