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

レシピ集 · 第8章 · 表

英語とスペイン語のメタサイエンス論文

Ioannidisの2005年の論文を1つのスクリプトで2つの版に組み直します。本文と表のセルに数式が入り、図1は論文の式から計算して描きます。

このページの内容

2〜3ページ(全7ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり210 × 280 mm
  • 2段, 段間6 mm
  • Gelasio 9.4/13
  • Sofia Sans Semi Condensed
  • 7ページ
  • レベル
  • Postext 1.65.0
  • 組版時間749 ms
  • コード232行

かんたんな説明

多くの研究結果がなぜ再現されないのかを論じた有名なオープンアクセス論文を、7ページの抜き刷りとして組んだものです。1つのスクリプトが英語の原文とスペイン語訳を作り、それぞれがその言語のハイフネーション、小数点の書き方、ラベルを使います。

できあがり

John Ioannidisの論文Why Most Published Research Findings Are False(PLoS Medicine、2005年)を抄録し、210 × 280 mmの2段組みのページに組んだ7ページの抜き刷りです。1ページ目は紺の帯で始まり、表題の後ろに論文自身の式の曲線が淡く描かれています。3つの式は番号付きのディスプレイ数式で、2×2表のどのセルにも本物のαとβを使った式が入ります。図1は式(2)から計算し、表4の最後の列も同じ式から計算します。同じスクリプトがスペイン語訳も組み、スペイン語のハイフネーション、表と図の小数コンマ、« »の引用符、スペイン語のラベルを使います。最後に、論文の文献リストからBibTeXに起こし直した33件のバンクーバー方式の参考文献が続きます。

このレシピが答える質問

  • 1つのスクリプトから、同じ論文を2つの言語で、それぞれの言語の組版規則に従って出すには?
  • 見出し行、結合セル、列幅、セルごとのそろえを備えた表を作るには?
  • 数式(インライン、ディスプレイ、方程式)を組み、PDFでもベクターのまま保つには?
  • arXivやPubMed Centralのオープンアクセス論文を、引用・図・ライセンス表記を保ったままPostextで組み直すには?

手短な答え

script.js · 32〜54行コード全体で見る
// The Cookbook composes the pen once per edition: content.<LANG>.md and each named slot
// replace the @content markers. What else follows the language is set here.
const edition = {
  // Hyphenation patterns and the words the engine writes (Tabla, Continúa) follow the locale.
  locale: t({ en: 'en-us', es: 'es' }),
  // Table 1 / Tabla 1, Figure 1 / Figura 1, counted through the essay; tables caption above.
  resourceTypes: defaultResourceTypes(LANG).map((type) => ({ ...type, shortLabel: type.name,
    numberingTemplate: '{n}', resetOn: 'never',
    ...(type.id === 'table' && { captionStyle: { position: 'above' } }) })),
  // Vancouver numbers in brackets, [2–4]; the CSL locale writes the list's words (2nd ed.,
  // 2.ª ed.). The titles of the works stay in English in both editions.
  citations: { style: 'elsevier-vancouver', locale: t({ en: 'en-US', es: 'es-ES' }),
    marker: 'brackets', collapseRanges: true,
    bibliography: { fontSize: em(0.78), lineHeight: pt(9.4), entrySpacing: pt(0.8),
      labelWidth: mm(6.4), doi: 'hide' } },
};
// The numbers the script writes (Table 4's PPV, the figure axes) take the edition's decimal
// sign, 0.85 or 0,85. Formulas keep their symbols; content.es.md writes 0{,}05 inside $…$
// so that TeX sets no space after the comma.
const number = (x, digits = 2) => x.toLocaleString(t({ en: 'en-US', es: 'es-ES' }),
  { minimumFractionDigits: digits, maximumFractionDigits: digits });
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
await initMathEngine(); // before the tables are built (gotcha: math-bundle)

材料

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

作り方

#1 · 1つのスクリプト、2つの版

コードは上の手短な答えです。Cookbookは言語ごとにスクリプトを1回ずつ組み立て、@contentの印がある場所にcontent.en.mdかcontent.es.mdを入れます。名前付きのスロット(content.corollaries.es.md、content.resources.es.md)も同じ規則に従い、スペイン語のファイルがないスロットは英語のものを使います。2つの版が1つのBibTeXファイルを共有できるのはこのためです。言語で変わるそのほかのものはすべてLANGを通ります。localeがハイフネーションのパターンを選び(スペイン語を分綴するコードは'es')、defaultResourceTypes(LANG)がTablaとFiguraを書き、CSLのロケールが文献リストの語を書き、toLocaleStringがスクリプトの計算した数値に小数コンマを付けます。訳文はスペイン語の正書法に従い、引用符は« »、本文では0,05、数式の中では0{,}05と書きます。こうするとTeXがコンマを句読点として扱って後ろに空白を入れることがありません。自分の論文を2つの言語で出すなら、本文とキャプションを言語ごとのファイルに分け、そのほかの違いはeditionのような1つのオブジェクトにまとめます。

#2 · 表のセルの中の数式

script.js · 414〜439行コード全体で見る
// A cell, a caption or a note sets $…$ as the text does (postext ≥ 1.19): MathJax paths at
// the cell's 8 pt, on the baseline of its line and aligned with the cell, vector in the PDF.
// The faces' latin files have no α or β (gotcha: latin-subset); the formulas need none.
const [CELL_PT, PAD] = [8, 1]; // cell type (pt), cell padding (mm)
function tableModel(tsv, widths, headerRows, merges = [], right = []) {
  let model = { ...parseTSV(tsv, { headerRows }), columnWidths: widths };
  model.rows.forEach((_, row) => right.forEach((c) => {
    model = setAlignment(model, { row, col: c }, 'right'); // the numbers, the PPV and their heads
  }));
  for (const range of merges) model = mergeCells(model, range); // gotcha: merged-cells-hiddenby
  return model;
}
// "Research finding" over both header rows, "True relationship" over Yes, No and Total.
const twoByTwo = (tsv) => tableModel(tsv, [1.1, 1.6, 1.6, 2.5], 2, [
  { start: { row: 0, col: 0 }, end: { row: 1, col: 0 } },
  { start: { row: 0, col: 1 }, end: { row: 0, col: 3 } }]);
// Table 4's last column is computed from Eq. (2), α = 0.05: two significant figures, as in 2005.
const ppv = (power, R, u, alpha = 0.05) => (power * R + u * (1 - power) * R)
  / (R + alpha - (1 - power) * R + u - u * alpha + u * (1 - power) * R);
const read = (s) => Number(s.replace(',', '.'));
const odds = (s) => s.split(':').map((x) => Number(x.replace(/\D/g, ''))).reduce((a, b) => a / b);
const ppvRows = (tsv) => tsv.split('\n').map((line, r) => {
  const [power, R, u, example, head] = line.split('\t');
  const p = ppv(read(power), odds(R), read(u)); // 0.0010: as many decimals as 2 figures need
  return [power, R, u, example, r ? number(p, 1 - Math.floor(Math.log10(p))) : head].join('\t');
}).join('\n');

postext 1.19から、表のセルは本文と同じように$…$を組みます。TSVで$c(1-\beta)R/(R+1)$と書いたセルはそのまま数式になり、セルの8 ptの大きさでMathJaxのパスとして描かれ、セルの行のベースラインに乗るので、Yes、Noと式が1本の線にそろい、PDFではベクターの輪郭になります。Fontsourceのlatinファイルにはギリシャ文字がありませんが、式には必要ありません。キャプションと注にも数式が書けるので、2005年の原文どおり、表4のキャプションは検出力を1 − βと書き、注はα = 0.05を仮定します。setAlignmentは表4の数値を右にそろえ、mergeCellsはResearch findingを2行の見出しにまたがらせ、True relationshipを3列にまたがらせて、結合セルに必要な隠れたセルも書き込みます。

#3 · スロットから表とキャプション、式から数値

script.js · 443〜471行コード全体で見る
const parsed = blocks.trim().split(/\n\s*\n/).map((block) => {
  const fields = {};
  const tsv = block.split('\n').filter((line) => {
    const m = /^(id|caption|note|alt): (.*)$/.exec(line);
    if (m) fields[m[1]] = m[2];
    return !m;
  }).join('\n');
  return { ...fields, tsv };
});
const tables = parsed.filter((b) => b.tsv).map(({ id, caption, note, tsv }) => {
  const model = id === 'tbl-ppv'
    ? tableModel(ppvRows(tsv), [0.8, 0.95, 0.75, 3.8, 1.05], 1, [], [0, 1, 2, 4])
    : twoByTwo(tsv);
  return { id, typeId: 'table', kind: 'table', createdAt: 0, updatedAt: 0, caption, note,
    table: { model }, placement: { position: 'auto', ...(id !== 'tbl-ppv' && { span: 'page' }) } };
});
const figures = parsed.filter((b) => !b.tsv).map(({ id, caption, note, alt }) => ({ id,
  typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0, caption, note, altText: alt,
  placement: { position: 'auto', span: 'page' },
  svg: { fileId: `${id}.svg`, width: FIG_W * 10, height: FIG_H * 10 } }));
const resources = [...tables, ...figures,
  { id: 'band-art', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
    svg: { fileId: 'band-art.svg', width: 1400, height: BAND * 10 } }];
const tableStyle = { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
  headerBackground: col('navy'), headerColor: col('paper'), headerBold: true,
  headerFontFamily: SANS, headerFontSize: pt(CELL_PT), bodyFontFamily: SANS,
  bodyFontSize: pt(CELL_PT), bodyColor: col('ink'), cellPadding: mm(PAD) };
const captionStyle = { fontFamily: SANS, fontSize: pt(8.2), color: col('ink'), labelBold: true,
  labelColor: col('accent'), gap: mm(2), note: { fontSize: pt(7), color: col('muted') } };

表、キャプション、注、代替テキストはcontent.resources.<lang>.mdにリソースごとに1ブロックずつ置きます。翻訳者はテキストファイルだけを直せばよく、各版には自分の言語だけが入ります。表4のPPV列は手で打ちません。ppv()が各行の検出力、R、uから計算し、9つの値は2005年に印刷された値と有効数字2桁で一致します。表はposition: 'auto'でフロートするので、表1は次のページでほかのフロートと重なることなく、それを引用したページの下に収まります。

#4 · 式(2)から描く図1

script.js · 475〜524行コード全体で見る
const R2 = (x) => Math.round(x * 100) / 100;
// Each label names the label face: loadSvg embeds it for the canvas (inlineSvgFonts), and the
// PDF asks the provider for it.
const mix = (f) => `#${[1, 3, 5].map((i) => Math.round(parseInt(palette.navy.slice(i, i + 2), 16)
  * (1 - f) + parseInt(palette.accent.slice(i, i + 2), 16) * f).toString(16).padStart(2, '0'))
  .join('')}`; // navy for the first curve, vermilion for the last
const label = (x, y, s, size, extra = '', fill = palette.muted) => `<text x="${R2(x)}" `
  + `y="${R2(y)}" font-size="${size}" font-family="${SANS}" fill="${fill}" ${extra}>${s}</text>`;
const line = (points, stroke, width, extra = '') => `<path d="M${points.map(([x, y]) =>
  `${R2(x)} ${R2(y)}`).join('L')}" fill="none" stroke="${stroke}" stroke-width="${width}" `
  + `${extra}/>`;
// Three panels, power 0.80, 0.50 and 0.20; PPV in % against R from 0 to 1, one curve per value.
function panels(curve, values, name, digits, dashed) {
  const [pw, top, plotH, left] = [52, 12, 34, 8]; // panel width, plot top and height, y labels
  let out = '';
  [0.8, 0.5, 0.2].forEach((power, p) => {
    const x0 = p * (pw + (FIG_W - 3 * pw) / 2) + left;
    const X = (R) => x0 + R * (pw - left - 2);
    const Y = (v) => top + plotH * (1 - v);
    const trace = (f) => Array.from({ length: 101 }, (_, k) => [X(k / 100), Y(f(k / 100))]);
    out += label(x0 - left, 4, `${'ABC'[p]}  <tspan font-weight="400">${t({ en: 'Power',
      es: 'Potencia' })} ${number(power)}</tspan>`, 3.4, '', palette.navy);
    if (!p) out += label(x0 - left, top - 4, t({ en: 'PPV (%)', es: 'VPP (%)' }), 2.8);
    for (const v of [0, 0.2, 0.4, 0.6, 0.8, 1]) {
      out += line([[X(0), Y(v)], [X(1), Y(v)]], palette.rule, v ? 0.15 : 0.3)
        + label(X(0) - 1.4, Y(v) + 1, v * 100, 2.6, 'text-anchor="end"')
        + label(X(v), Y(0) + 3.6, number(v, v % 1 ? 1 : 0), 2.6, 'text-anchor="middle"');
    }
    if (dashed) out += line(trace((R) => dashed(power, R)), palette.muted, 0.35,
      'stroke-dasharray="1 0.8"');
    values.forEach((value, i) => {
      out += line(trace((R) => curve(power, R, value)), mix(i / (values.length - 1)), 0.6);
    });
    out += label(X(0.5), Y(0) + 8, `${t({ en: 'Pre-study odds', es: 'Razón previa' })}, `
      + '<tspan font-style="italic">R</tspan>', 2.9, 'text-anchor="middle"');
  });
  const key = values.map((value, i) => line([[48 + i * 24, 57.8], [54 + i * 24, 57.8]],
    mix(i / (values.length - 1)), 0.8) + label(56 + i * 24, 58.8, `<tspan font-style="italic">`
    + `${name}</tspan> = ${number(value, digits)}`, 2.9)).join('');
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${FIG_W * 10}" height="${FIG_H * 10}" `
    + `viewBox="0 0 ${FIG_W} ${FIG_H}">${out}${key}</svg>`;
}
// Eq. (3): n independent studies of equal power, no bias.
const teams = (power, R, n, alpha = 0.05) => (R * (1 - (1 - power) ** n))
  / (R + 1 - (1 - alpha) ** n - R * (1 - power) ** n);
const bandArt = () => `<svg xmlns="http://www.w3.org/2000/svg" width="1400" height="${BAND * 10}" `
  + `viewBox="0 0 140 ${BAND}">${Array.from({ length: 10 }, (_, i) => line(Array.from(
    { length: 81 },
    (_, k) => [10 + k * 1.6, 92 - 76 * ppv(0.8, k / 80, i / 10)]), palette.mist, 0.5,
  `stroke-opacity="${R2(0.5 - i * 0.04)}"`)).join('')}</svg>`;

各パネルは、表4を埋めるのと同じppv()でRを0から1まで動かします。式から曲線を描くと、2005年の図が隠していたことがわかります。元の図の曲線はu = 0、0.05、0.20、0.80に対応しているのに、凡例には0.05、0.20、0.50、0.80とあります。この版は凡例の値で描き、偏りのない曲線を破線で加え、キャプションの注でそのことを説明します。ラベルはラベル用の書体を指定した文字です。loadSvgが図をinlineSvgFontsに通し、Canvasのためにその書体を埋め込みます。PDFはフォントプロバイダーが渡す書体で組みます。

#5 · 論文の1ページ目と囲み

script.js · 58〜81行コード全体で見る
const text = (id, content, family, size, color, placement, extra) => ({ kind: 'text', id,
  content, fontFamily: family, fontSize: pt(size), color: col(color), align: 'left',
  overflow: 'wrap', placement, ...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) => ({ fontWeight, letterSpacing: pt(size * 0.18),
  textTransform: 'uppercase' });
const BAND = 100; // mm from the top of the trim to the foot of the band
const titleBlock = { enabled: true, minHeight: mm(BAND + 12 - TOP), slot: { elements: [
  { kind: 'box', id: 'band', style: { backgroundColor: col('navy') },
    placement: { anchor: { to: 'bleed', edge: 'top-left' },
      size: { width: 'fill', height: mm(BAND + 3) } } }, // + the 3 mm bleed
  { kind: 'image', id: 'curves', resourceId: 'band-art', // Eq. (2), faint, for u = 0 to 0.9
    placement: at('page', 'top-left', 128, 46, 76) }, // under the title, clear of the text
  text('kicker', '{attr.kicker}', SANS, 8, 'mist', at('page', 'top-left', INNER, 20, 120),
    caps(8)),
  text('title', '{titleText}', SANS, 36, 'paper', at('#kicker', 'below', 0, 6, 150),
    { fontWeight: 800, lineHeight: 1.02 }),
  text('author', '{attr.author}', SERIF, 13, 'paper', at('#title', 'below', 0, 8, 150)),
  text('affiliation', '{attr.affiliation}', SANS, 8, 'mist', at('#author', 'below', 0, 1.6, 150),
    { lineHeight: 1.35 }),
  text('source', '{attr.source}', SANS, 7.4, 'muted', at('page', 'top-left', INNER, BAND + 4,
    MEASURE), { lineHeight: 1.35 }),
] } };

表題は唯一のレベル1の見出しです。そのスタイルessayはページ全幅にわたり、見出しの属性から帯、見出しラベル、著者、所属、出典の行を描くので、スペイン語版では言葉を変えるだけです。要旨は地色を敷いたページ幅の囲みです。計算例である囲み1はページの下に2段にまたがってフロートし、囲みの中の文章を2段に組みます。系は論文どおり段落の頭に太字の主張を置く形を保ち、:chip[Corollary 1]{style="corollary"}がその前に朱色の小さなラベルを付けます。

script.js · 130〜159行コード全体で見る
const calloutStyles = [
  { id: 'summary', span: 'page', background: col('tint'), marginTop: pt(0),
    marginBottom: pt(LEAD), padding: { top: mm(4), right: mm(6), bottom: mm(4), left: mm(6) },
    titleStyle: { fontFamily: SANS, fontSize: pt(8), ...caps(8), color: col('accent'),
      gap: mm(1.5) },
    body: { fontSize: pt(9.4), lineHeight: pt(13), firstLineIndent: pt(0) } },
  { id: 'box', span: 'page', placement: 'bottom', columnGap: mm(GUTTER),
    backgroundEnabled: false, border: { enabled: false },
    stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('navy') },
    padding: { top: mm(2.5), right: mm(0), bottom: mm(1), left: mm(0) },
    marginTop: pt(LEAD), marginBottom: pt(LEAD),
    titleStyle: { fontFamily: SANS, fontSize: pt(9), fontWeight: 700, color: col('navy'),
      gap: mm(1.2) },
    body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.2), firstLineIndent: mm(3) } },
  // The journal's first-page note (competing interests, abbreviation) floated to the foot of
  // the first column under a hairline, as PLoS Medicine sets it.
  { id: 'note', placement: 'bottom', backgroundEnabled: false, border: { enabled: false },
    stripe: { enabled: true, side: 'top', width: pt(0.5), color: col('rule') },
    padding: { top: mm(1.6), right: mm(0), bottom: mm(0), left: mm(0) },
    marginTop: pt(LEAD), marginBottom: pt(0),
    body: { fontFamily: SANS, fontSize: pt(7.6), lineHeight: pt(10.4), color: col('muted'),
      boldColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0) } },
];
// :chip[Corollary 1]{style="corollary"}: a label in the sans and the accent, no frame.
const chipStyles = [{ id: 'corollary', fontFamily: SANS, fontSize: em(0.86), bold: true,
  color: col('accent'), backgroundEnabled: false, borderWidth: pt(0), paddingX: em(0),
  gap: em(0.35) }];
const paragraphStyles = [{ id: 'colophon', fontFamily: SANS, fontSize: pt(7.6),
  lineHeight: pt(10.4), color: col('muted'), boldColor: col('ink'), textAlign: 'left',
  firstLineIndent: pt(0), spaceBetween: pt(3) }];

誌面1ページ目の注記(利益相反と略語)は note スタイルのボックスで、placement: 'bottom' を指定しています。収まる最初の段の下端へ、細い罫の下に送られ、英語版の1ページ目は2段の終わりがそろいます。headings.balancing.fillShortColumns は段落を1行長く組むことを許し、最終ページの参考文献の2段をそろえて終わらせます。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 141 · A metascience essay in English and Spanish ═══════
// https://postext.dev/en/cookbook/bilingual-metascience-essay
// Code: MIT · Text: J. P. A. Ioannidis, PLoS Med 2005 (CC BY) · Figures: drawn in code (CC BY 4.0)
// Fonts: Gelasio, Sofia Sans Semi Condensed (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
  buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage,
  registerCitationEngine, defaultResourceTypes, initMathEngine, parseTSV, mergeCells, setAlignment,
  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 = 'bilingual-metascience-essay';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a navy for the furniture, one vermilion accent, every colour linked
const palette = { ink: '#1c1d24', navy: '#22305a', accent: '#b8442a', tint: '#eceff5',
  rule: '#b4bccb', muted: '#5a6070', mist: '#c3cde6', paper: '#ffffff' };
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.navy })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS] = ['Gelasio', 'Sofia Sans Semi Condensed'];
// mm: the 210 × 280 trim, head, foot, inner and outer margins, and the gutter
const [TRIM_W, TRIM_H, TOP, BOTTOM, INNER, OUTER, GUTTER] = [210, 280, 22, 22, 19, 17, 6];
const MEASURE = TRIM_W - INNER - OUTER; // 174 mm across both columns
const [BODY, LEAD] = [9.4, 13]; // pt
const [FIG_W, FIG_H] = [MEASURE, 60]; // mm: Figures 1 and 2, across both columns

// #region answer: one script, two editions: LANG picks the text, the language and the numbers
// The Cookbook composes the pen once per edition: content.<LANG>.md and each named slot
// replace the @content markers. What else follows the language is set here.
const edition = {
  // Hyphenation patterns and the words the engine writes (Tabla, Continúa) follow the locale.
  locale: t({ en: 'en-us', es: 'es' }),
  // Table 1 / Tabla 1, Figure 1 / Figura 1, counted through the essay; tables caption above.
  resourceTypes: defaultResourceTypes(LANG).map((type) => ({ ...type, shortLabel: type.name,
    numberingTemplate: '{n}', resetOn: 'never',
    ...(type.id === 'table' && { captionStyle: { position: 'above' } }) })),
  // Vancouver numbers in brackets, [2–4]; the CSL locale writes the list's words (2nd ed.,
  // 2.ª ed.). The titles of the works stay in English in both editions.
  citations: { style: 'elsevier-vancouver', locale: t({ en: 'en-US', es: 'es-ES' }),
    marker: 'brackets', collapseRanges: true,
    bibliography: { fontSize: em(0.78), lineHeight: pt(9.4), entrySpacing: pt(0.8),
      labelWidth: mm(6.4), doi: 'hide' } },
};
// The numbers the script writes (Table 4's PPV, the figure axes) take the edition's decimal

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

アレンジ

#引用番号を上付きにする

医学誌はバンクーバー方式の番号をよく上付きで組みます。

-    marker: 'brackets', collapseRanges: true,
+    marker: 'superscript', collapseRanges: true,

#DOIを印刷する

このレシピのBibTeXは、スクリプトの大きさに収めるためDOIを含めていません。自分のファイルでは残しておき、リンクとして印刷します。

-      labelWidth: mm(6.4), doi: 'hide' } },
+      labelWidth: mm(6.4), doi: 'link' } },

#表を1段に組む

式の短い2×2表なら1段に収まります。span: 'page'を外します(表4にはこの指定がありません)。1段の表の例は番号付きの数式がある2段組みの論文にあります。

よくあるつまずき

つまずき

数式には最初のビルドの前に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つ読み込まれます。 数式 →

つまずき

Fontsourceのファイルは文字を収め、記号は収めない

キットは各書体のFontsourceのlatinファイルを埋め込み、本文にč、ł、†があればlatin-extファイルを、α、χがあればgreekファイル(それを持つファミリーのみ。LoraとGelasioにはない)を、画面でもPDFでも加えます。→、≈、✓、★などの記号はどのファイルにもなく、PDFでは欠けます。図として描くか、数式で書くか、それを収めたファイルを持つ書体を選んでください。 PDFに埋め込むフォント →

つまずき

結合セルにはhiddenByのプレースホルダーが要る。mergeCellsを使う

セルは行の配列内の位置で配置されるため、結合セルが広がる位置にはhiddenByを付けたプレースホルダーのセルが必要です。HTMLのように省くと、それ以降の列がすべてずれます。結合はmergeCellsで作ってください。postext 1.5からは、グリッドが不ぞろいな表はdoc.contentWarningsにraggedTableGridとして報告され、parseTSV(text, { headerRows })でヘッダー行を指定できます。 データから作る表 →

つまずき

裸の$は数式を開く。\$と書く

ドル記号はインライン数式を開くため、$40のような価格は数式の始まりになります。\$40と書いてください。 エスケープとそのままの文字 →

  • 2005年の文献リストが5人の著者のあとにet al.と書いているところは、BibTeXの著者リストをand othersで終えます。elsevier-vancouverはそこにet al.を印刷します(postext 1.19から。以前の版はothersという名前の共著者を印刷していました)。
  • 2つの版でページは一致しません。スペイン語の本文のほうが長く、表4が1ページ後ろに来ます。キャプチャは両方の版の1、2、3、5、6、7ページを公開し、画像の重さを上限内に収めながら、どちらの版でも表4が見えるようにしています。

クレジット

レシピ
Ignacio Ferro
本文
  • “Why Most Published Research Findings Are False”, PLoS Medicine 2(8): e124 (2005), doi:10.1371/journal.pmed.0020124, open access under the Creative Commons Attribution License; abridged, tables and figures redrawn; Spanish translation made for the Cookbook · John P. A. Ioannidis · CC BY
フォント
Gelasio (SIL OFL 1.1) · Sofia Sans Semi Condensed (SIL OFL 1.1)
SandboxPDF