跳到主要内容
食谱编号141

排版食谱 · 第8章 · 表

英西双语的元科学论文

用一个脚本把Ioannidis 2005年的论文重排成两个版本:正文和表格单元格里都有公式,图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行代码

简单来说

一篇著名的开放获取论文,讨论为什么许多研究结果站不住脚,排成七页的抽印本。同一个脚本生成英文原版和西班牙文译本,各有自己的断词、小数点写法和标签。

成品一览

John Ioannidis的论文Why Most Published Research Findings Are False(PLoS Medicine,2005)的七页抽印本,经过删节,排在210 × 280 mm的双栏页面上。首页由一条深蓝色色带开头,标题后面淡淡地画着论文自己那个公式的曲线。三个公式排成带编号的行间公式;2×2表的每个单元格里都是公式,α和β是真正的希腊字母;图1由公式(2)算出,表4的最后一栏也由同一个公式算出。同一个脚本还排出西班牙文译本:西班牙文断词,表格和图里用小数逗号,引号用« »,标签也是西班牙文。最后是33条温哥华格式的参考文献,按论文的参考文献表重建为BibTeX。

这道食谱解答

  • 怎样用同一个脚本以两种语言发布同一篇论文,并遵循各自语言的排版规范?
  • 怎样做一个有表头行、合并单元格、栏宽和逐格对齐的表?
  • 怎样排数学公式(行内、行间、编号公式),并在PDF中保持矢量?
  • 怎样用Postext重新排版arXiv或PubMed Central上的开放获取论文,并保留引用、图和许可声明?

简短回答

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 · 一个脚本,两个版本

代码就是上面的简短回答。Cookbook为每种语言各组装一次脚本,把content.en.md或content.es.md放到@content标记所在的位置;每个具名槽位(content.corollaries.es.md、content.resources.es.md)也照此处理,没有西班牙文文件的槽位就用英文的,两个版本因此共用一个BibTeX文件。其他随语言变化的东西都经过LANG:locale选择断词规则('es'是西班牙文断词的代码),defaultResourceTypes(LANG)写出Tabla和Figura,CSL的区域设置写出参考文献表里的词,toLocaleString让脚本算出的数字使用小数逗号。译文遵循西班牙文的排版习惯:引号用« »,正文写0,05,公式里写0{,}05,这样TeX不会把逗号当成标点、在后面加空格。要把自己的论文出成两种语言,就为正文和图表说明各准备一个语言文件,其余差异都集中在一个像edition这样的对象里。

#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和公式站在同一条线上,PDF里是矢量轮廓。Fontsource的latin文件没有希腊字母,公式也用不到它们。题注和附注同样可以写公式:表4的题注把检验效能写成1 − β,附注写α = 0.05,与2005年的原文一致。setAlignment让表4的数字右对齐,mergeCells让“Research finding”跨两行表头、“True relationship”跨三栏,并写出合并单元格需要的隐藏占位单元格。

#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里,每个资源一块,译者只需改文本文件,每个版本也只带自己的语言。表4的PPV一栏不是手敲的:ppv()用每一行的检验效能、R和u算出它,九个值与2005年印出的值在两位有效数字上一致。表格以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>`;

每个面板让R从0走到1,用的是填写表4的同一个ppv()。按公式画曲线,暴露出2005年那张图掩盖的一点:原图的曲线对应的是u = 0、0.05、0.20和0.80,图例写的却是0.05、0.20、0.50和0.80。这个版本按图例的值画,再用虚线加上无偏倚的曲线,并在题注的附注里说明。图中标签是写明标签字体的文字:loadSvg把图交给inlineSvgFonts,由它嵌入这款字体供画布使用,PDF则用字体提供者给的字体来排。

#5 · 论文的首页和方框

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 }),
] } };

标题是唯一的一级标题;它的样式essay横跨整页,用标题属性画出色带、栏目标签、作者、单位和来源行,所以西班牙文版只需换文字。摘要是带底色的通栏标注框。方框1是计算实例,浮到某一页的页脚,横跨两栏,框内文字再分两栏。推论保留原文的段首粗体句式::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) }];

期刊首页的注释(利益冲突声明和缩写)是一个 note 样式的框,设为 placement: 'bottom':它落到第一个放得下它的栏的栏底,上方一条细线,英文版第1页的两栏因此齐平收尾。headings.balancing.fillShortColumns 允许某个段落多排一行,让最后一页的两栏参考文献齐平结束。

完整食谱

沙盒
// ═══ 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' } },

#表格排在一栏里

公式较短的2×2表可以放进一栏:去掉它的span: 'page',表4就没有这一项。单栏表格的例子见带编号公式的双栏论文。

常见问题

易错点

数学公式需要在首次构建前await initMathEngine()

在数学引擎运行之前排版的公式是灰色的占位方框。从https://esm.sh/postext连同其他符号一起导入initMathEngine,并在首次构建前await它;含有数学公式的文档不经这一步就构建时,控制台会打印一条警告。从postext 1.5起,MathJax作为一个模块随包发布,由initMathEngine去获取,所以从CDN直接导入就能用,不需要?bundle(1.4及以前,所有符号都必须来自https://esm.sh/postext?bundle)。只从一个URL导入:两个URL会加载两个引擎。 数学 →

易错点

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年的参考文献列出五位作者后写et al.的地方,BibTeX的作者列表以and others结尾,elsevier-vancouver在那里印出et al.(postext 1.19起;更早的版本会印出一个名叫others的合著者)。
  • 两个版本的页面并不对应:西班牙文更长,表4晚一页出现。截图发布两个版本的第1、2、3、5、6、7页,既不超出图片大小限制,又能在两个版本里都看到表4。

致谢

文本
  • “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)
沙盒PDF