Skip to main content
Recipe number 137

Cookbook · Chapter 6 · Boxes & notes

An AI preprint with prompt exemplars in boxes

The chain-of-thought paper re-set: prompts and model outputs in tabbed boxes side by side, author–year citations from BibTeX, charts drawn from its tables.

  • Trim 215.9 × 279.4 mm
  • 2 columns, 7 mm gutter
  • Newsreader 9.6/12.8
  • IBM Plex Mono
  • IBM Plex Sans
  • 7 pages
  • Level
  • Postext 1.65.0
  • Laid out in 698 ms
  • 247 lines of code

In short

A famous AI paper, shortened and laid out again. Its example prompts and the model's answers sit in labelled boxes side by side, with a tick or a cross on each answer, and the charts are drawn from the paper's numbers.

What you'll build

Seven pages of a machine-learning preprint on US letter: Wei et al.'s Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, abridged from its arXiv version under CC BY 4.0. The first page carries the paper's best-known figure, set as boxes rather than pasted as a picture: standard prompting on the left, chain-of-thought prompting on the right, each prompt in a box tabbed Model Input and each answer in a box tabbed Model Output, the exemplars in IBM Plex Mono and the chain of thought in bold colour, with a cross on the wrong answer and a tick on the right one. The text cites the way NeurIPS papers do, (Brown et al., 2020), from the paper's own reference list rebuilt as BibTeX. Table 2 and two charts are redrawn from the numbers the paper publishes.

This recipe answers

  • How do I set an AI paper's prompt and model-output examples in boxes side by side?
  • How do I re-set an open-access paper from arXiv or PubMed Central with Postext, keeping its citations, figures and licence line?
  • How do I cite works and build the bibliography in APA, IEEE or another citation style?

The short answer

script.js · lines 32–56in full code
// :::columns{count=2 breaks="4"} inside the "figure" box opens the right column at its fourth
// block; each nested box counts as one block.
const tab = (fill) => ({ fontFamily: SANS, fontSize: pt(7), fontWeight: 600,
  color: col('paper'), background: col(fill), position: 'top-left', inset: mm(3),
  height: mm(4.2), offset: mm(2.1), paddingX: mm(2.2) }); // straddles the top edge
const exemplar = (id, fill, ink, extra) => ({ id, background: col(fill),
  border: { enabled: true, color: col('rule'), width: pt(0.6) }, borderRadius: mm(2.4),
  padding: { top: mm(4.4), right: mm(3), bottom: mm(2.6), left: mm(3) },
  marginTop: mm(4.2), marginBottom: ZERO, label: tab(ink),
  body: { fontFamily: MONO, fontSize: pt(7.8), lineHeight: pt(10.4), color: col('ink'),
    boldColor: col(ink), // **…** marks the chain of thought: the highlight of the original
    textAlign: 'left', hyphenation: false, paragraphSpacing: true, firstLineIndent: ZERO },
  ...extra });
const mark = (id) => ({ icon: { kind: 'resource', resourceId: id, size: mm(5.6),
  position: 'corner', cornerSide: 'right' } }); // a badge on the top-right corner
const promptBoxes = [
  { id: 'figure', span: 'page', backgroundEnabled: false, border: { enabled: false },
    padding: mm(0), columnGap: mm(6), marginTop: ZERO, marginBottom: pt(LEAD),
    body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.4), color: col('ink'),
      boldColor: col('accent'), textAlign: 'left', paragraphSpacing: true,
      firstLineIndent: ZERO } },
  exemplar('input', 'tint', 'accent'),
  exemplar('right', 'mint', 'green', mark('mark-right')),
  exemplar('wrong', 'mint', 'green', mark('mark-wrong')),
];

Figure 1 as boxes: two columns, a tab on each box, a ✓ or ✗ in the corner

Ingredients

Type
Newsreader, IBM Plex Sans, IBM Plex Mono (SIL OFL 1.1)
Assets
None: every picture is drawn in code

Method

#1 · Figure 1 is three box styles

The code is the short answer above. The figure is one page-wide box with no frame of its own; inside it, :::columns{count=2 breaks="4"} opens the right column at the fourth block, and every nested box counts as one block. The prompt and answer boxes share one style factory, so they differ only in fill, tab colour and the badge on the corner: a callout icon with position: 'corner' takes an SVG resource, which is how the ✓ and ✗ reach the page in a document whose fonts have no such glyphs. In your own paper, write each exemplar as plain paragraphs inside a box and mark the reasoning with **…**; the box style's boldColor turns that into the highlight.

#2 · Author–year citations, natbib style

script.js · lines 60–70in full code
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
// Chicago author-date writes (Brown et al. 2020); ML venues put a comma before the year.
const AUTHOR_YEAR = '<group delimiter=" ">\n            <text macro="author-inline"/>';
const natbib = STYLES['chicago-author-date']
  .replace(AUTHOR_YEAR, AUTHOR_YEAR.replace('" "', '", "'));
const citations = { style: 'custom', customStyle: natbib, link: true,
  bibliography: { fontSize: em(0.8), lineHeight: pt(10.2), entrySpacing: pt(1.8),
    hangingIndent: mm(4), doi: 'text' } };
// The text's two web addresses are links: clickable in the PDF, printed in parentheses on
// paper, `[name census data](https://namecensus.com/)` as "name census data (namecensus.com)".
const links = { print: 'inline', urlDisplay: 'short' };

ML venues use natbib's author–year look: a comma between the names and the year, et al. from three authors on. Chicago author-date is the bundled style closest to it, so the recipe edits one group of its CSL, the one that joins author and year, from a space to a comma. Bring your own .bib file as it is: paste it into a :::references{format=bibtex} block, cite with [@key] for (Brown et al., 2020) and @key for Brown et al. (2020). A suffix keeps the comma written before it and its emphasis, so [@brown2020language, *inter alia*] prints (Brown et al., 2020, inter alia) as the paper does. Captions cite the same way: Figure 4's caption writes @jie2022learning and @lan2021mwptoolkit, and both works enter the reference list with no nocite.

The two web addresses in the text, the name census data in section 5 and the licence in the colophon, are written as links, [name census data](https://namecensus.com/). With links: { print: 'inline', urlDisplay: 'short' } the paper prints each address in parentheses after its text, without https://, and the PDF keeps the link. An address typed as plain text prints the same but goes nowhere when clicked.

#3 · The title block

script.js · lines 74–91in full code
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, y, width = MEASURE) => ({ anchor: { to, edge },
  offset: { x: ZERO, y: mm(y) }, size: { width: mm(width), height: 'auto' } });
const titleBlock = { enabled: true, minHeight: mm(58), slot: { elements: [
  text('venue', '{attr.venue}', MONO, 7.5, { fontWeight: 500, letterSpacing: pt(0.6),
    color: col('accent'), placement: at('container', 'top-left', 0) }),
  text('title', '{titleText}', SERIF, 23, { fontWeight: 600, lineHeight: 1.1,
    placement: at('#venue', 'below', 5) }),
  text('authors', '{attr.authors}', SANS, 9.6, { fontWeight: 500, lineHeight: 1.45,
    placement: at('#title', 'below', 6) }),
  text('affiliation', '{attr.affiliation}', SANS, 8.6, { color: col('muted'),
    placement: at('#authors', 'below', 1.2) }),
  { kind: 'rule', id: 'rule', thickness: pt(0.5), color: col('rule'),
    placement: at('#affiliation', 'below', 4) },
  text('note', '{attr.note}', SERIF, 8.2, { lineHeight: 1.35,
    color: col('muted'), placement: at('#rule', 'below', 2) }),
] } };

The title is the document's only level-1 heading, with a style that spans both columns and draws a designed block: venue line, title, authors in two rows, affiliation and a note on the abridgement. The authors and the note are heading attributes, and \n inside an attribute starts a new row, as \\ does in a LaTeX \author. For your own paper, change the attributes; the design stays.

#4 · Figure numbers that match the original

script.js · lines 95–106in full code
// Figure 1 is boxes, which the figure counter does not see: number the charts by type.
const numbered = (id, word, n, extra) => ({ id, name: `${word} ${n}`,
  shortLabel: `${word} ${n}`, captionPrefix: `${word} ${n}`, numberingTemplate: '',
  resetOn: 'never', counterFormat: 'decimal', ...extra });
const resourceTypes = [numbered('mark', 'Mark', ''), numbered('fig2', 'Figure', 2),
  numbered('fig4', 'Figure', 4),
  numbered('tab2', 'Table', 2, { captionStyle: { position: 'above' } })];
const ACROSS = { position: 'top', span: 'page' }; // a float over both columns
const svg = (id, typeId, file, [width, height], caption, note, altText, placement) => ({
  id, typeId, kind: 'svg', createdAt: 0, updatedAt: 0,
  placement: placement ?? { position: 'top' }, svg: { fileId: file, width, height },
  caption, note, altText });

The engine numbers figures in the order they are first cited, but Figure 1 here is a box, which the counter never sees. So the redrawn charts get a resource type each, with the number written into the label and an empty numberingTemplate, and keep the numbers of the arXiv version: Figure 2, Figure 4 and Table 2. In a paper of your own, where every figure is a resource, one figure type with numberingTemplate: '{n}' does the counting.

#5 · Table 2 from the paper's data

script.js · lines 480–508in full code
const SETS = ['GSM8K', 'SVAMP', 'ASDiv', 'AQuA', 'MAWPS'];
const RESULTS = [ // model, size, then standard / CoT pairs per benchmark; * CoT beats standard
  ['UL2', '20B', '4.1 4.4* 10.1 12.5* 16.0 16.9* 20.5 23.6* 16.6 19.1*'],
  ['LaMDA', '420M', '2.6 0.4 2.5 1.6 3.2 0.8 23.5 8.3 3.2 0.9'],
  ['', '2B', '3.6 1.9 3.3 2.4 4.1 3.8 22.9 17.7 3.9 3.1'],
  ['', '8B', '3.2 1.6 4.3 3.4 5.9 5.0 22.8 18.6 5.3 4.8'],
  ['', '68B', '5.7 8.2* 13.6 18.8* 21.8 23.1* 22.3 20.2 21.6 30.6*'],
  ['', '137B', '6.5 14.3* 29.5 37.5* 40.1 46.6* 25.5 20.6 43.2 57.9*'],
  ['GPT', '350M', '2.2 0.5 1.4 0.8 2.1 0.8 18.1 8.7 2.4 1.1'],
  ['', '1.3B', '2.4 0.5 1.5 1.7 2.6 1.4 12.6 4.3 3.1 1.7'],
  ['', '6.7B', '4.0 2.4 6.1 3.1 8.6 3.6 15.4 13.4 8.8 3.5'],
  ['', '175B', '15.6 46.9* 65.7 68.9* 70.3 71.3* 24.8 35.8* 72.7 87.1*'],
  ['Codex', '–', '19.7 63.1* 69.9 76.4* 74.0 80.4* 29.5 45.3* 78.7 92.6*'],
  ['PaLM', '8B', '4.9 4.1 15.1 16.8* 23.7 25.2* 19.3 21.7* 26.2 30.5*'],
  ['', '62B', '9.6 29.9* 48.2 46.7 58.7 61.9* 25.6 22.4 61.8 80.3*'],
  ['', '540B', '17.9 56.9* 69.4 79.0* 72.1 73.9* 25.2 35.8* 79.2 93.3*'],
];
const cell = (content, extra) => ({ content, align: 'right', ...extra });
const tableRows = () => [
  [cell('Model', { isHeader: true, align: 'left', colSpan: 2 }), { content: '',
    hiddenBy: { row: 0, col: 0 } }, // gotcha: merged-cells-hiddenby
  ...SETS.flatMap((set, i) => [cell(set, { isHeader: true, align: 'center', colSpan: 2 }),
    { content: '', hiddenBy: { row: 0, col: 2 + 2 * i } }])],
  [cell('', { isHeader: true }), cell('', { isHeader: true }),
    ...SETS.flatMap(() => [cell('standard', { isHeader: true }), cell('CoT', { isHeader: true })])],
  ...RESULTS.map(([model, size, values]) => [cell(model ? `**${model}**` : '', { align: 'left' }),
    cell(size, { align: 'left' }),
    ...values.split(' ').map((v) => cell(v.endsWith('*') ? `**${v.slice(0, -1)}**` : v))]),
];

The results are typed once, as the LaTeX source has them, and feed both Table 2 and Figure 4, so the chart cannot drift from the table. The benchmark names span two columns each; a merged cell needs a placeholder marked hiddenBy where it spreads. Bold marks the cells where chain-of-thought prompting beats standard prompting, as the green cells of the original do.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 137 · An AI preprint with prompt exemplars in boxes ═══════
// https://postext.dev/en/cookbook/ai-preprint-prompt-exemplars
// Code: MIT · Text: Wei et al. 2022, arXiv:2201.11903 (CC BY 4.0) · Charts: drawn in code
// Fonts: Newsreader, IBM Plex Sans, IBM Plex Mono (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine, registerResourceImage,
  inlineSvgFonts,
} 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 = 'ai-preprint-prompt-exemplars';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a cool ink, a prompt blue, an answer green and a red for the wrong answer
const palette = { ink: '#1b1e24', accent: '#1f5fa6', green: '#21744a', red: '#b3362d',
  tint: '#e9f0f8', mint: '#e6f2eb', rule: '#b4bcc8', muted: '#5b6270', 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, MONO] = ['Newsreader', 'IBM Plex Sans', 'IBM Plex Mono'];
// US letter, two columns of 85.5 mm as ML venues print.
const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 22, 22, 19, 7];
const MEASURE = TRIM_W - 2 * SIDE;
const COLUMN = (MEASURE - GUTTER) / 2;
const LEAD = 12.8; // pt
const ZERO = pt(0);

// #region answer: Figure 1 as boxes: two columns, a tab on each box, a ✓ or ✗ in the corner
// :::columns{count=2 breaks="4"} inside the "figure" box opens the right column at its fourth
// block; each nested box counts as one block.
const tab = (fill) => ({ fontFamily: SANS, fontSize: pt(7), fontWeight: 600,
  color: col('paper'), background: col(fill), position: 'top-left', inset: mm(3),
  height: mm(4.2), offset: mm(2.1), paddingX: mm(2.2) }); // straddles the top edge
const exemplar = (id, fill, ink, extra) => ({ id, background: col(fill),
  border: { enabled: true, color: col('rule'), width: pt(0.6) }, borderRadius: mm(2.4),
  padding: { top: mm(4.4), right: mm(3), bottom: mm(2.6), left: mm(3) },
  marginTop: mm(4.2), marginBottom: ZERO, label: tab(ink),
  body: { fontFamily: MONO, fontSize: pt(7.8), lineHeight: pt(10.4), color: col('ink'),
    boldColor: col(ink), // **…** marks the chain of thought: the highlight of the original
    textAlign: 'left', hyphenation: false, paragraphSpacing: true, firstLineIndent: ZERO },
  ...extra });
const mark = (id) => ({ icon: { kind: 'resource', resourceId: id, size: mm(5.6),
  position: 'corner', cornerSide: 'right' } }); // a badge on the top-right corner
const promptBoxes = [
  { id: 'figure', span: 'page', backgroundEnabled: false, border: { enabled: false },

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

#Cite in APA

APA writes (Roy & Roth, 2015) and lists up to twenty authors, which the bibliography of a large-model paper rarely wants.

-const citations = { style: 'custom', customStyle: natbib, link: true,
+const citations = { style: 'apa', link: true,

#Set the paper in one column

A NeurIPS-style single column needs wider side margins to keep a readable measure; the page-wide boxes then take the single column.

-const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 22, 22, 19, 7];
+const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 24, 24, 38, 7];
-  layout: { layoutType: 'double', gutterWidth: mm(GUTTER) },
+  layout: { layoutType: 'single' },

#Code listings in boxes

For prompts with code in them, the listing boxes of Code listings and keycaps show syntax colouring with bold and italic runs.

Pitfalls

Pitfall

A nested box ignores span, placement and snapToGrid

A callout nested in another ignores its span, placement, snapToGrid and floatBarrier: it always flows inside its parent, at the parent's inner width. Nested boxes →

Pitfall

Merged cells need hiddenBy placeholders: use mergeCells

Cells are laid out by their position in the row array, so a merged cell needs placeholder cells marked hiddenBy where it spreads; leaving them out, as HTML does, shifts every later column. Build merges with mergeCells. Since postext 1.5 a table whose grid is irregular is reported in doc.contentWarnings as raggedTableGrid, and parseTSV(text, { headerRows }) marks the head rows. Tables from data →

  • A page-wide box in a two-column layout goes on the current page only when it fits with at least a couple of body lines below it. Figure 1 sits on page 1 because the abstract is set in 9.3 pt with tight padding; a longer abstract sends the figure to page 2.

Credits

Text
Fonts
Newsreader (SIL OFL 1.1) · IBM Plex Sans (SIL OFL 1.1) · IBM Plex Mono (SIL OFL 1.1)
SandboxPDF