In short
The 2016 letter that announced the first gravitational waves, shortened and set again on US Letter pages. The signal of both detectors, drawn from the public data, runs across page 1; references are numbered in brackets.
What you'll build
Five pages of the letter that announced the first gravitational waves, Observation of Gravitational Waves from a Binary Black Hole Merger (Abbott et al., 2016), abridged and re-set on US Letter in two columns. Page 1 opens with the evidence: the strain recorded at Hanford and Livingston, redrawn from the open data files of the Gravitational Wave Open Science Center, runs across both columns under the title. Below it come the collaboration byline with its footnote, the abstract across the page and the text, with citations numbered [1,2] and [25–27] as the APS journals print them. The chirp mass is equation (1). Table I sets its asymmetric errors as stacked super- and subscripts, written as maths in the cells, and the captions print the letter's own formulas. Bring your own BibTeX and data files, and the same script sets your letter.
This recipe answers
- How do I set a physics letter: a collaboration byline, the abstract across both columns and a data figure across the top?
- How do I control where a figure goes: top of page, across both columns, exactly here, or in the margin?
- How do I typeset maths (inline, display, equations) and keep it vector in the PDF?
- How do I re-set an open-access paper from arXiv or PubMed Central with Postext, keeping its citations, figures and licence line?
The short answer
// [@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
Physics citations [1] and [2–4], from the bundled IEEE style
Ingredients
- Features
- Figures exactly hereFigure placementCitations in a citation styleMathematicsTables from dataNumbered captionsCustom resource typesCaption styleSource and credit linesFootnotesBoxes across the pageCallout boxesHeading stylesNumbered headingsHeading attributesDesigned openersRunning heads and foliosBibliography from the referencesParagraph stylesPDF export
- Also uses
- Citations that place figuresFigure and Table in your languageHeads by page roleFonts embedded in the PDFFigures and tables as resourcesSuperscripts and subscriptsLine breaks in titlesUnnumbered chaptersExplicit vertical space
- Type
- Gelasio, Albert Sans (SIL OFL 1.1)
- Assets
- None: every picture is drawn in code
Method
#1 · Numbered physics citations from the IEEE file
The code is the short answer above. postext-citeproc bundles no APS style, and the bundled ieee style is the nearest: citation order, numbers in brackets, initials before the family name. Four string replacements on STYLES.ieee close the gap. collapse="citation-number" joins runs ([25–27]), one pair of brackets on the layout prints [1,2], et-al-min rises to eleven so a list of ten authors stays whole, and a new <bibliography> block prints the reference the way Physical Review does, with the journal, the volume in bold, the page and the year: Phys. Rev. Lett. 74, 3515 (1995). The 43 works come in a :::references{format=bibtex} block of their own; a name in double braces such as {{J. Aasi et al.}} is printed as written, which is how the letter cites its own collaboration's long author lists. See Citations and bibliography.
#2 · Figure 1 under the title, across both columns
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) },
];
A float never stands above the line that cites it, and the text first cites Figure 1 in Section II, so as a float it could not reach page 1. The letter puts it there directly: ::resource{id="fig1"} comes right after the title, and its placement, { position: 'here', span: 'page' }, sets it across both columns at that point, with the columns going on under it. The byline and the abstract follow in a page-wide box, front, whose :::paragraphs blocks centre the byline and set the dates small. The footnote marker after et al. sends its note to the foot of the first column, as the APS journals print the author note, and footnotes.numberFormat: 'lower-alpha' letters the notes so they never read as references. See Block embed and Footnotes.
#3 · Table I, with maths in its cells
// 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 }]) } };
A table cell sets $…$ as the text does (since postext 1.19), so each value is written as TeX, $36^{+5}_{-4}\,M_\odot$, and its two errors stack over and under the number, scaled to the cell's line; Markdown's ^+5^~−4~ would print them one after the other. Captions and notes take the same maths: Figure 2 writes $R_S = 2GM/c^2$ and Figure 4 $5.1\sigma$, set in MathJax's glyphs, which have the Greek that neither text face carries, and the PDF keeps them as vector paths. The resource types print FIG. 1 and TABLE I in the captions and Fig. 1 and Table I in the text: a captionPrefix, and counterFormat: 'upper-roman' for tables. See Mathematical formulas.
#4 · Figures drawn from the open 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' } }));
The four figures are drawn in code from the data files GWOSC publishes with the letter, under CC BY 4.0. Each trace keeps every eighth sample, 430 points for the 0.21 s of Figure 1, and stored as one base-64 character per point for its change from the previous one, which keeps the five traces under 3 KB inside the script. The residual row is the data less the waveform, as published. Hanford is orange and Livingston blue in every figure, and the text keeps the page's ink and one blue. The labels are MathJax paths in its sans-serif face (\textsf), so an exponent or a symbol on an axis is set like the formulas of the text, and the PDF keeps every line and label as vectors.
The whole recipe
// ═══ 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=", ">/,
The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)
Variations
#Use the bundled IEEE style as it ships
Drop the edits and the references read [2], [3], [4] in the text and A. Einstein, “title”, journal… in the list.
-const citations = { style: 'custom', customStyle: aps, link: true,
+const citations = { style: 'ieee', link: true,#Raise the numbers as Nature does
Nature's style sets superscript numbers and lists titles; it is bundled.
-const citations = { style: 'custom', customStyle: aps, link: true,
+const citations = { style: 'nature', link: true,#Set it on A4
Change the trim; the measure, the columns and every figure follow from it.
-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];Pitfalls
Pitfall
Maths needs await initMathEngine() before the first build
Formulas laid out before the maths engine is running are grey placeholder boxes. Import initMathEngine from https://esm.sh/postext with the other symbols and await it before the first build; a document with maths built without it prints one console warning. Since postext 1.5 MathJax ships inside the package as one module that initMathEngine fetches, so the plain import works from a CDN and ?bundle is not needed (up to 1.4 every symbol had to come from https://esm.sh/postext?bundle). Import from one URL only: two URLs load two engines. Mathematics →
- Up to postext 1.18 a
'here'resource withspan: 'page'was set one column wide in a two-column flow, and a$in a caption or a cell printed as typed. Pin 1.19 or later. - A Greek letter, ⊙ or ≃ typed as a character in a caption or a cell falls back to a system face on screen and is missing from the PDF, which embeds the Latin files of each face. Write it as maths,
$\sigma$or$M_\odot$, and draw it in figures. - A list of hundreds of authors does not belong in a BibTeX file. Write the name as the journal prints it, in double braces:
author={{B. Abbott et al.}}. - Keep the licence line of the paper and of the data. Here a footnote and the colophon say what was cut, and each caption's note names the data and what the redrawn figure leaves out.
Credits
- Recipe
- Ignacio Ferro
- Text
- 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
- Fonts
- Gelasio (SIL OFL 1.1) · Albert Sans (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


