跳到主要内容
食谱编号142

排版食谱 · 第7章 · 图与图片

带CONSORT流程图的临床试验报告

一篇真实试验的节选重排:横跨全页的结构式摘要,用试验数字在代码中绘制的CONSORT流程图,小数对齐的结果表,APA引用。

本页内容
  • 英文样例:尚无中文版本
  • 成品尺寸210 × 280 mm
  • 2栏, 栏间距7 mm
  • Lora 9.4/13
  • Nunito Sans
  • 8页
  • 难度
  • Postext 1.18.0
  • 排版用时192 ms
  • 226行代码

简单来说

一项已发表的研究:一个提供治疗练习的聊天机器人。文章经节选后重新排版。谁进入、谁退出试验的流程图按文中的数字绘制,表格里的小数上下对齐,参考文献采用APA格式。

成品一览

一项数字心理健康领域的随机对照试验,按其开放获取的全文重新排版:2017年发表在JMIR Mental Health上的Woebot试验。Woebot是一个提供认知行为疗法的对话代理,全文节选为八页。版式是210 × 280 mm的平实研究报告,正文用Lora,所有标签和数字用Nunito Sans,只有一个靛蓝色强调色。页面包含试验报告所需的内容:横跨两栏的结构式摘要,关键词和注册行,按论文自身数字在代码中重绘的CONSORT受试者流程,小数对齐的两张结果表,逐字保留的作者利益冲突声明,以及由BibTeX生成的APA 7著者-出版年引用。正文保持发表时的英文。

这道食谱解答

  • 怎样为临床试验报告绘制CONSORT流程图并排结构式摘要?
  • 怎样做一个有表头行、合并单元格、栏宽和逐格对齐的表?
  • 怎样按APA、IEEE或其他引用样式引用文献并生成参考文献表?
  • 怎样用Postext重新排版arXiv或PubMed Central上的开放获取论文,并保留引用、图和许可声明?

简短回答

script.js · 第30–51行在完整代码中
// The abstract is a box whose span is 'page': the columns close above it and open again
// under it. Inside, :::columns sets Background to Results in two columns; the keywords and
// the registration line run across the box under them.
const abstractBox = { id: 'abstract', span: 'page', background: col('tint'),
  padding: { top: mm(3.5), right: mm(4.5), bottom: mm(3), left: mm(4.5) },
  marginTop: pt(0), marginBottom: pt(LEAD), columnGap: mm(7),
  titleStyle: { fontFamily: SANS, fontSize: pt(8.5), fontWeight: 800, letterSpacing: pt(1.6),
    textTransform: 'uppercase', color: col('accent'), gap: mm(2) },
  body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.4), textAlign: 'left',
    firstLineIndent: pt(0), paragraphSpacing: true, boldColor: col('accent'),
    boldFontWeight: 800, italicColor: col('ink') } };
// The CONSORT diagram is an SVG drawn in code from the trial's numbers (see #region art),
// declared as a resource and placed by its first :ref, at the head of the next page.
const consort = { id: 'fig-consort', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
  placement: { position: 'top', span: 'page' },
  svg: { fileId: 'consort.svg', width: 1760, height: CONSORT_H * 10 },
  caption: 'Participant flow through the trial (CONSORT diagram).',
  note: 'Redrawn from Figure 1 of the original; the Analysis row follows the Statistical '
    + 'Analysis section. The text reports 58 participants with T2 data.',
  altText: 'Flow chart: 204 registrations, 115 confirmed, 45 excluded as bot-generated, 70 '
    + 'randomized; 34 to Woebot (3 lost, 31 with T2 data) and 36 to the information-only '
    + 'control (11 lost, 25 with T2 data); 34 and 36 analysed.' };

用料

类型
Lora, Nunito Sans(SIL OFL 1.1)
素材
无:所有图片都用代码绘制

做法

#1 · 摘要框和作为资源的流程图

代码就是上面的简短回答。span: 'page'的框样式在上方结束两栏、在下方重新开始两栏,所以摘要可以在页面任意高度横跨全宽。框内的:::columns{count=2}把Background到Conclusions分成两栏,关键词和注册行接着横跨整个框。CONSORT流程图和其他SVG资源一样:编号、图注和出处说明都来自资源,第一次:ref把它放到下一页顶部。

#2 · 用标题属性排文章头部

script.js · 第55–78行在完整代码中
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 = { fontFamily: SANS, fontWeight: 800, letterSpacing: pt(1.5),
  textTransform: 'uppercase' };
const titleBlock = { enabled: true, minHeight: mm(70), slot: { elements: [
  { kind: 'rule', id: 'bar', thickness: pt(2.5), color: col('accent'),
    placement: at('container', 'top-left', 0, 0, MEASURE) },
  text('kind', '{attr.kind}', SANS, 8, { ...caps, color: col('accent'),
    placement: at('#bar', 'below', 0, 3, MEASURE) }),
  text('title', '{titleText}', SERIF, 18.5, { fontWeight: 700, lineHeight: 1.17,
    placement: at('#kind', 'below', 0, 3.5, MEASURE - 8) }),
  text('authors', '{attr.authors}', SANS, 10, { fontWeight: 700, inlineMarks: true,
    placement: at('#title', 'below', 0, 4.5, MEASURE) }),
  text('affiliations', '{attr.affiliations}', SANS, 7.4, { inlineMarks: true, lineHeight: 1.4,
    color: col('muted'), placement: at('#authors', 'below', 0, 1.8, MEASURE) }),
  { kind: 'rule', id: 'hair', thickness: pt(0.5), color: col('rule'),
    placement: at('#affiliations', 'below', 0, 2.6, MEASURE) },
  text('history', '{attr.history}', SANS, 7.2, { color: col('muted'),
    placement: at('#hair', 'below', 0, 1.6, MEASURE) }),
  text('source', '{attr.source}', SANS, 7.2, { fontWeight: 700, color: col('accent'),
    placement: at('#history', 'below', 0, 0.8, MEASURE) }),
] } };

标题是文档中唯一的一级标题,其样式横跨全页并由元素绘制。其余内容都来自标题属性:文章类型,带^1^单位标记的作者(inlineMarks把它排成上标),用\n分行的单位,收稿和接受日期,以及出处行。排自己的论文时,改属性、保留设计即可。样式上的numbered: false让图编号为图1、2、3,而不是1.1。

#3 · 按数字绘制CONSORT流程

script.js · 第514–644行在完整代码中
const n2 = (v) => +v.toFixed(2);
const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;');
// An SVG drawn as an image cannot see the page's web fonts (gotcha: svg-no-webfonts), so each
// drawing carries its faces inline, as data URLs of the Fontsource files.
async function inlineFaces(family, weights) {
  const id = family.toLowerCase().replace(/\s+/g, '-');
  let css = '';
  for (const w of weights) {
    const url = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@5/files/${id}-latin-${w}`
      + '-normal.woff2';
    const bytes = new Uint8Array(await (await fetch(url)).arrayBuffer());
    let bin = '';
    for (const b of bytes) bin += String.fromCharCode(b);
    css += `@font-face{font-family:F;font-weight:${w};src:url(data:font/woff2;base64,`
      + `${btoa(bin)}) format('woff2')}`;
  }
  return `<style>${css}text{font-family:F}</style>`;
}
const label = (x, y, s, size, weight, fill, anchor = 'middle') => `<text x="${n2(x)}" `
  + `y="${n2(y)}" font-size="${size}" font-weight="${weight}" fill="${fill}" `
  + `text-anchor="${anchor}">${esc(s)}</text>`;
// A box of centred lines: the first bold, an "n = …" line bold in the accent (white on a
// filled box), the rest regular. Every box is 64, 56 or 26 mm wide; lines 1.3 × the size.
function node(cx, y, w, lines, { size = 2.6, fill = palette.tint, stroke = palette.accent } = {}) {
  const lh = size * 1.3;
  const h = lines.length * lh + 2.2;
  const solid = fill === palette.accent;
  let svg = `<rect x="${n2(cx - w / 2)}" y="${n2(y)}" width="${w}" height="${n2(h)}" rx="1.2" `
    + `fill="${fill}" stroke="${stroke}" stroke-width="0.3"/>`;
  lines.forEach((s, i) => {
    const isN = /^n = /.test(s);
    svg += label(cx, y + 1.1 + lh * (i + 0.78), s, size, i === 0 || isN ? 800 : 400,
      solid ? palette.paper : isN ? palette.accent : palette.ink);
  });
  return { svg, h, top: y, bottom: y + h, mid: y + h / 2 };
}
// Arrows are a line plus a filled triangle path: no <marker> (gotcha: svg-no-marker-filters).
const line = (pts) => `<path d="M${pts.map(([x, y]) => `${n2(x)} ${n2(y)}`).join('L')}" `
  + `fill="none" stroke="${palette.ink}" stroke-width="0.3"/>`;
function arrow(pts) {
  const [[x0, y0], [x1, y1]] = pts.slice(-2);
  const a = Math.atan2(y1 - y0, x1 - x0);
  const p = (d, s) => `${n2(x1 - Math.cos(a) * d + Math.sin(a) * s)} `
    + `${n2(y1 - Math.sin(a) * d - Math.cos(a) * s)}`;
  return line([...pts.slice(0, -1), [x1 - Math.cos(a) * 1.4, y1 - Math.sin(a) * 1.4]])
    + `<path d="M${n2(x1)} ${n2(y1)}L${p(1.8, 0.9)}L${p(1.8, -0.9)}Z" fill="${palette.ink}"/>`;
}
// The four CONSORT stages as pills at the left edge, each centred on a y.
const stage = (y, s) => `<rect x="0" y="${n2(y - 2.2)}" width="${n2(s.length * 1.9 + 5)}" `
  + `height="4.4" rx="2.2" fill="${palette.ink}"/>`
  + label(2.5, y + 0.85, s.toUpperCase(), 2.3, 800, palette.paper, 'start');
function consortSvg(face) { // 176 mm wide, the full measure; one unit is a millimetre
  const [W, L, R, MID] = [176, 59, 117, 88];
  const side = { size: 2.5, fill: palette.paper, stroke: palette.rule };
  const a = node(MID, 0.5, 64, ['Registrations received by email', 'n = 204']);
  const b = node(MID, a.bottom + 3, 64, ['Responded to the email confirmation', 'n = 115']);
  const x = node(150, b.bottom + 0.5, 52, ['Excluded as ineligible', 'n = 45',
    'deemed bot-generated'], side);
  const c = node(MID, x.bottom + 2, 64, ['Randomized by computer algorithm', 'n = 70'],
    { fill: palette.accent });
  const split = c.bottom + 4; // the line that divides the sample between the arms
  const parts = [a.svg, b.svg, x.svg, c.svg, stage(a.mid, 'Enrollment'),
    arrow([[MID, a.bottom], [MID, b.top]]), arrow([[MID, b.bottom], [MID, c.top]]),
    arrow([[MID, x.mid], [124, x.mid]]), stage(split, 'Allocation'),
    line([[MID, c.bottom], [MID, split]]), line([[L, split], [R, split]])];
  const arms = [[L, 13, 'Allocated to Woebot', 34, 'up to 20 sessions over 2 weeks', 3, 31],
    [R, 163, 'Allocated to information-only control', 36, 'NIMH ebook on depression', 11, 25]];
  for (const [cx, sx, title, n, what, gone, kept] of arms) {
    const box = node(cx, split + 3.5, 56, [title, `n = ${n}`, what]);
    const lost = node(sx, box.bottom + 4.5, 26, ['Lost to follow-up', `n = ${gone}`], side);
    const t2 = node(cx, lost.bottom + 2, 56, ['Provided data at T2', `n = ${kept}`]);
    const an = node(cx, t2.bottom + 5.5, 56, ['Analysed (intention to treat)', `n = ${n}`,
      'missing T2 data imputed'], { fill: palette.accent });
    parts.push(box.svg, lost.svg, t2.svg, an.svg, arrow([[cx, split], [cx, box.top]]),
      arrow([[cx, box.bottom], [cx, t2.top]]), arrow([[cx, lost.mid], [sx + (sx < MID ? 13
        : -13), lost.mid]]), arrow([[cx, t2.bottom], [cx, an.top]]));
    if (cx === R) parts.push(stage(lost.top - 3, 'Follow-up'), stage(t2.bottom + 2.75, 'Analysis'));
  }
  return `<svg xmlns="http://www.w3.org/2000/svg" width="1760" height="${CONSORT_H * 10}" `
    + `viewBox="0 0 ${W} ${CONSORT_H}">${face}${parts.join('')}</svg>`;
}
// Figures 3 and 4 of the original are thematic maps; here they are bars, one per subtheme.
const THEMES = [
  { id: 'fig-best', file: 'best.svg', themes: [['Process', 31, [['Checking in / accountability', 9],
    ['Empathy / personality', 7], ['Learning', 12, [['Emotions', 5], ['General insight', 5],
      ['Cognitions', 2]]], ['Conversation', 3]]], ['Content', 16, [['Videos', 7], ['Games', 3],
    ['Suggestions', 2], ['Weekly graphs', 1]]]],
  caption: 'Best features of the Woebot experience: themes of the answers to “What was the best '
    + 'thing about your experience using Woebot?”',
  note: 'Number of participants per theme. Redrawn as bars from the thematic map in Figure 3 of '
    + 'the original; numbers as printed there.',
  alt: 'Bars for Process (31): checking in 9, empathy 7, learning 12 (emotions 5, general '
    + 'insight 5, cognitions 2), conversation 3; Content (16): videos 7, games 3, suggestions 2, '
    + 'weekly graphs 1.' },
  { id: 'fig-worst', file: 'worst.svg', themes: [['Process violations', 15,
    [['Not being able to converse naturally', 10], ['Repetitive', 2], ['Miscellaneous', 3]]],
  ['Technical problems', 8, [['Glitches', 4], ['Looping', 4]]], ['Content', 8,
    [['Emoticons', 2], ['Interactions too short', 2], ['Videos too long', 2], ['Other', 2]]]],
  caption: 'Least favored experiences: themes of the answers to “What was the worst thing about '
    + 'your experience of using Woebot?”',
  note: 'Number of participants per theme. Redrawn as bars from the thematic map in Figure 4 of '
    + 'the original; numbers as printed there.',
  alt: 'Bars for Process violations (15): not conversing naturally 10, repetitive 2, '
    + 'miscellaneous 3; Technical problems (8): glitches 4, looping 4; Content (8): emoticons, '
    + 'short interactions, long videos and other, 2 each.' },
];
const rows = (themes) => themes.flatMap(([name, n, subs]) => [{ name, n, depth: 0 },
  ...subs.flatMap(([s, k, deeper = []]) => [{ name: s, n: k, depth: 1 },
    ...deeper.map(([d, m]) => ({ name: d, n: m, depth: 2 }))])]);
const ROW = 4.4;
function themeHeight(id) { return rows(THEMES.find((f) => f.id === id).themes).length * ROW + 2; }
function themeSvg({ id, themes }, face) { // 84.5 mm wide: one column
  const [W, X0, X1] = [84.5, 48, 79];
  const H = themeHeight(id);
  let svg = '';
  rows(themes).forEach(({ name, n, depth }, i) => {
    const y = 1 + i * ROW;
    if (!depth) {
      svg += `<path d="M0 ${n2(y + 0.2)}H${W}" stroke="${palette.rule}" stroke-width="0.25"/>`
        + label(0, y + 3.1, `${name} (${n})`, 2.75, 800, palette.ink, 'start');
      return;
    }
    const w = (n / 12) * (X1 - X0);
    svg += label(depth * 3 - 1, y + 3, name, 2.45, 400, palette.ink, 'start')
      + `<rect x="${X0}" y="${n2(y + 0.9)}" width="${n2(w)}" height="2.6" `
      + `fill="${depth === 1 ? palette.accent : palette.soft}"/>`
      + label(X0 + w + 1.2, y + 3, String(n), 2.55, 800, palette.ink, 'start');
  });
  return `<svg xmlns="http://www.w3.org/2000/svg" width="845" height="${Math.round(H * 10)}" `
    + `viewBox="0 0 ${W} ${n2(H)}">${face}${svg}</svg>`;
}

每个框是一次带文字行的node()调用;阶段是左边缘的胶囊标签,箭头是一条线加一个实心三角形,因为<marker>在PDF中会退回为图片。数字都来自试验:204人报名,115人确认,排除45个机器人生成的报名,分配34人和36人,失访3人和11人,T2有数据的31人和25人。排自己的试验时,替换文字和计数即可,布局会随框高变化。作为图片绘制的SVG看不到页面字体,所以图中以数据URL内嵌了Nunito Sans。

#4 · 表格中对齐的数字

script.js · 第459–510行在完整代码中
// Nunito Sans sets tabular figures, so numbers right-aligned in a column line up on the
// decimal point; the (SD) or (SE) sits in a column of its own, flush left beside it.
// aligns: one letter per column, l or r; header cells over the numbers are centred.
const cell = (content, align, head) => ({ content, ...(head && { isHeader: true }),
  align: head && align !== 'left' ? 'center' : align });
function grid(rows, widths, aligns, heads, spans) { // spans: [row, col, lastRow, lastCol]
  const a = [...aligns].map((k, c) => (c && k === 'r' ? 'right' : 'left'));
  let m = { headerRowCount: heads, columnWidths: widths,
    rows: rows.map((row, r) => widths.map((_, c) => cell(row[c] ?? '', a[c], r < heads))) };
  for (const [r0, c0, r1, c1] of spans) {
    m = mergeCells(m, { start: { row: r0, col: c0 }, end: { row: r1, col: c1 } });
  }
  return m; // mergeCells marks the covered cells hiddenBy (gotcha: merged-cells-hiddenby)
}
const pair = (s) => s.split(' '); // '13.25 (5.17)' → ['13.25', '(5.17)']
const BASE = [['Depression (PHQ-9)', '13.25 (5.17)', '14.30 (6.65)'],
  ['Anxiety (GAD-7)', '19.02 (4.27)', '18.05 (5.89)'],
  ['Positive affect', '26.19 (8.37)', '25.54 (9.58)'],
  ['Negative affect', '28.74 (8.92)', '24.87 (8.13)'], ['Age, mean (SD)', '21.83 (2.24)',
    '22.58 (2.38)'], ['**Gender, n (%)**'], ['Male', '4 (7)', '7 (21)'],
  ['Female', '20 (55)', '27 (79)'], ['**Ethnicity, n (%)**'], ['Latino/Hispanic', '2 (8)', '2 (6)'],
  ['Non-Latino/Hispanic', '22 (92)', '32 (94)'], ['Caucasian', '18 (75)', '28 (82)'],
  ['Non-Caucasian', '6 (25)', '6 (18)']];
const ITT = [['PHQ-9', '13.67 (.81)', '12.07-15.27', '11.14 (0.71)', '9.74-12.32', '6.03',
  '.017', '0.44'], ['GAD-7', '16.84 (.67)', '15.52-18.56', '17.35 (0.60)', '16.16-18.13', '0.38',
  '.581', '0.14'], ['PANAS positive affect', '26.02 (1.45)', '23.17-28.86', '26.88 (1.29)',
  '24.35-29.41', '0.17', '.707', '0.02'], ['PANAS negative affect', '27.53 (1.42)',
  '24.73-30.32', '25.98 (1.24)', '23.54-28.42', '0.91', '.912', '0.344']];
const table = (id, model, span, caption, note) => ({ id, typeId: 'table', kind: 'table',
  createdAt: 0, updatedAt: 0, placement: { position: 'top', span }, caption, note,
  table: { model } });
const baseline = grid([['', 'Information control', '', 'Woebot', ''],
  ['**Scale, mean (SD)**'], ...BASE.map(([k, a, b]) => (a ? [k, ...pair(a), ...pair(b)] : [k]))],
[26, 13, 10, 13, 10], 'lrlrl', 1, [[0, 1, 0, 2], [0, 3, 0, 4], [1, 0, 1, 4], [7, 0, 7, 4],
  [10, 0, 10, 4]]);
const itt = grid([['', 'Information-only control', '', '', 'Woebot', '', '', '*F*', '*P*',
  '*d*^c^'], ['', 'T2^a^', '', '95% CI^b^', 'T2^a^', '', '95% CI^b^', '', '', ''],
...ITT.map(([k, a, ca, b, cb, ...s]) => [k, ...pair(a), ca, ...pair(b), cb, ...s])],
[30, 10, 9, 18, 10, 9, 18, 8, 8, 8], 'lrlrrlrrrr', 2, [[0, 0, 1, 0], [0, 1, 0, 3],
  [0, 4, 0, 6], [1, 1, 1, 2], [1, 4, 1, 5], [0, 7, 1, 7], [0, 8, 1, 8], [0, 9, 1, 9]]);
const resources = () => [consort,
  table('tbl-baseline', baseline, 'column', 'Demographic and clinical variables of '
    + 'participants at baseline.', 'Participants with data at T2 (N=58), as printed in the '
    + 'original Table 1.'),
  table('tbl-itt', itt, 'page', 'Results of ITT analysis of entire sample on primary outcomes '
    + 'in the study at T2.', '^a^Baseline=pooled mean (standard error). ^b^95% confidence '
    + 'interval. ^c^Cohen *d* shown for between-subjects effects using means and standard '
    + 'errors at Time 2.'),
  ...THEMES.map(({ id, file, caption, note, alt }) => ({ id, typeId: 'figure', kind: 'svg',
    createdAt: 0, updatedAt: 0, placement: { position: 'auto' }, caption, note, altText: alt,
    svg: { fileId: file, width: 845, height: Math.round(themeHeight(id) * 10) } })),
];

Nunito Sans的数字等宽,所以一列右对齐的均值会在小数点上对齐。每个均值和它的标准差或标准误分成两列,均值右对齐,括号左对齐紧贴其旁;mergeCells构建分组表头(三列上方的"Information-only control")和横跨全表的行。表2是横跨全页的浮动体,表1留在一栏中。

#5 · 嵌套框中机器人的原话

script.js · 第82–95行在完整代码中
const bubbleTitle = { fontFamily: SANS, fontSize: pt(6.6), fontWeight: 800, letterSpacing: pt(1),
  textTransform: 'uppercase', color: col('muted'), gap: mm(0.8) };
const calloutStyles = [
  abstractBox,
  { id: 'chat', backgroundEnabled: false, marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(2.5), right: mm(0), bottom: mm(0.5), left: mm(0) },
    stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('accent') },
    titleStyle: { ...bubbleTitle, fontSize: pt(7.6), color: col('accent'), gap: mm(2) } },
  { id: 'bubble', background: col('tint'), borderRadius: mm(2.4), marginTop: mm(1.6),
    marginBottom: mm(0), padding: { top: mm(1.6), right: mm(3), bottom: mm(1.8), left: mm(3) },
    titleStyle: bubbleTitle,
    body: { fontFamily: SANS, fontSize: pt(8.8), lineHeight: pt(11.4), textAlign: 'left',
      firstLineIndent: pt(0), color: col('ink') } },
];

论文引用了机器人发出的五条消息。本例把它们收进一个顶部有靛蓝色色条的框,每条消息是一个圆角的嵌套框,带一个小标签,说明它所体现的特征。框中只有论文的引文,没有任何增补。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 142 · A clinical trial report with a CONSORT diagram ══════
// https://postext.dev/en/cookbook/clinical-trial-consort-flow
// Code: MIT · Text: Fitzpatrick, Darcy & Vierhile 2017 (CC BY 4.0), abridged · Figures: code
// Fonts: Lora, Nunito Sans (SIL OFL 1.1) · Needs postext ≥ 1.18.0
import {
  buildDocument, renderPageToCanvas, clearMeasurementCache, registerCitationEngine,
  registerResourceImage, defaultResourceTypes, mergeCells,
} 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 = 'clinical-trial-consort-flow';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a violet-tinted ink and one indigo accent; the control arm in a pale tint
const palette = { ink: '#1f1d2b', accent: '#4a3f8c', soft: '#a39cd0', tint: '#efedf7',
  rule: '#c7c2de', muted: '#5b586b', 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] = ['Lora', 'Nunito Sans'];
const [TRIM_W, TRIM_H, TOP, BOTTOM, INNER, OUTER, GUTTER] = [210, 280, 22, 22, 18, 16, 7];
const MEASURE = TRIM_W - INNER - OUTER; // 176 mm
const LEAD = 13; // pt: 9.4 pt Lora in two columns of 84.5 mm
const CONSORT_H = 107; // mm: the height of the CONSORT drawing (its resource is × 10 px)

// #region answer: a structured abstract across both columns, and a figure drawn from numbers
// The abstract is a box whose span is 'page': the columns close above it and open again
// under it. Inside, :::columns sets Background to Results in two columns; the keywords and
// the registration line run across the box under them.
const abstractBox = { id: 'abstract', span: 'page', background: col('tint'),
  padding: { top: mm(3.5), right: mm(4.5), bottom: mm(3), left: mm(4.5) },
  marginTop: pt(0), marginBottom: pt(LEAD), columnGap: mm(7),
  titleStyle: { fontFamily: SANS, fontSize: pt(8.5), fontWeight: 800, letterSpacing: pt(1.6),
    textTransform: 'uppercase', color: col('accent'), gap: mm(2) },
  body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.4), textAlign: 'left',
    firstLineIndent: pt(0), paragraphSpacing: true, boldColor: col('accent'),
    boldFontWeight: 800, italicColor: col('ink') } };
// The CONSORT diagram is an SVG drawn in code from the trial's numbers (see #region art),
// declared as a resource and placed by its first :ref, at the head of the next page.
const consort = { id: 'fig-consort', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
  placement: { position: 'top', span: 'page' },
  svg: { fileId: 'consort.svg', width: 1760, height: CONSORT_H * 10 },
  caption: 'Participant flow through the trial (CONSORT diagram).',
  note: 'Redrawn from Figure 1 of the original; the Analysis row follows the Statistical '
    + 'Analysis section. The text reports 58 participants with T2 data.',
  altText: 'Flow chart: 204 registrations, 115 confirmed, 45 excluded as bot-generated, 70 '
    + 'randomized; 34 to Woebot (3 lost, 31 with T2 data) and 36 to the information-only '
    + 'control (11 lost, 25 with T2 data); 34 and 36 analysed.' };
// #endregion

// #region title: the article head across the page: kind, title, authors, history, source
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 = { fontFamily: SANS, fontWeight: 800, letterSpacing: pt(1.5),
  textTransform: 'uppercase' };
const titleBlock = { enabled: true, minHeight: mm(70), slot: { elements: [
  { kind: 'rule', id: 'bar', thickness: pt(2.5), color: col('accent'),
    placement: at('container', 'top-left', 0, 0, MEASURE) },
  text('kind', '{attr.kind}', SANS, 8, { ...caps, color: col('accent'),
    placement: at('#bar', 'below', 0, 3, MEASURE) }),
  text('title', '{titleText}', SERIF, 18.5, { fontWeight: 700, lineHeight: 1.17,
    placement: at('#kind', 'below', 0, 3.5, MEASURE - 8) }),
  text('authors', '{attr.authors}', SANS, 10, { fontWeight: 700, inlineMarks: true,
    placement: at('#title', 'below', 0, 4.5, MEASURE) }),
  text('affiliations', '{attr.affiliations}', SANS, 7.4, { inlineMarks: true, lineHeight: 1.4,
    color: col('muted'), placement: at('#authors', 'below', 0, 1.8, MEASURE) }),
  { kind: 'rule', id: 'hair', thickness: pt(0.5), color: col('rule'),
    placement: at('#affiliations', 'below', 0, 2.6, MEASURE) },
  text('history', '{attr.history}', SANS, 7.2, { color: col('muted'),
    placement: at('#hair', 'below', 0, 1.6, MEASURE) }),
  text('source', '{attr.source}', SANS, 7.2, { fontWeight: 700, color: col('accent'),
    placement: at('#history', 'below', 0, 0.8, MEASURE) }),
] } };
// #endregion

// #region boxes: the bot's quoted messages as chat bubbles inside a box with a top stripe
const bubbleTitle = { fontFamily: SANS, fontSize: pt(6.6), fontWeight: 800, letterSpacing: pt(1),
  textTransform: 'uppercase', color: col('muted'), gap: mm(0.8) };
const calloutStyles = [
  abstractBox,
  { id: 'chat', backgroundEnabled: false, marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(2.5), right: mm(0), bottom: mm(0.5), left: mm(0) },
    stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('accent') },
    titleStyle: { ...bubbleTitle, fontSize: pt(7.6), color: col('accent'), gap: mm(2) } },
  { id: 'bubble', background: col('tint'), borderRadius: mm(2.4), marginTop: mm(1.6),
    marginBottom: mm(0), padding: { top: mm(1.6), right: mm(3), bottom: mm(1.8), left: mm(3) },
    titleStyle: bubbleTitle,
    body: { fontFamily: SANS, fontSize: pt(8.8), lineHeight: pt(11.4), textAlign: 'left',
      firstLineIndent: pt(0), color: col('ink') } },
];
// #endregion

const head = (id, content, parity, edge, x, extra) => text(id, content, SANS, 7.6, {
  parity, pages: 'body', fontWeight: 600, letterSpacing: pt(0.3), color: col('muted'),
  overflow: 'clip', placement: at('page', edge, x, 12.5, 110), ...extra });
const folio = { fontWeight: 800, color: col('accent') };
const right = { align: 'right' }; // anchored top-right, an element ends at its offset
const header = { elements: [
  head('v-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
  head('v-title', 'Fitzpatrick, Darcy & Vierhile · JMIR Ment Health 2017;4(2):e19', 'even',
    'top-left', OUTER + 8),
  head('r-title', 'Woebot for symptoms of depression and anxiety · a randomized trial', 'odd',
    'top-right', -OUTER - 8, right),
  head('r-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, { ...folio, ...right }),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'bottom-right', -OUTER,
  { ...folio, ...right, pages: 'opener', placement: at('page', 'bottom-right', -OUTER, -12, 10) }),
] };

registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const sans = (size, weight) => ({ fontFamily: SANS, fontSize: pt(size), fontWeight: weight });
const small = (id, size, lead, extra) => ({ id, fontFamily: SANS, fontSize: pt(size),
  lineHeight: pt(lead), textAlign: 'left', firstLineIndent: pt(0), ...extra });
const config = () => ({ // a factory: the engine caches resolved configs per object
  locale: 'en-us',
  // "Table 1" over its table, "Figure 1" under its figure; one count, not 1.1 (title unnumbered)
  resourceTypes: defaultResourceTypes(LANG).map((type) => ({ ...type,
    ...(type.id === 'table' && { captionStyle: { position: 'above' } }) })),
  colorPalette, calloutStyles, header, footer,
  // Psychology reports cite in APA 7: (Kessler et al., 2007), Bickmore et al. (2005).
  citations: { style: 'apa', link: true,
    bibliography: { fontSize: em(0.86), lineHeight: pt(10.6), hangingIndent: mm(4),
      entrySpacing: pt(2.4), doi: 'link' } },
  headingStyles: [
    { id: 'article', numbered: false, span: 'page', advancedDesign: titleBlock },
    { id: 'back', ...sans(8, 800), letterSpacing: pt(1.3), textTransform: 'uppercase',
      color: col('accent'), lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0) },
  ],
  page: { sizePreset: 'custom', width: mm(TRIM_W), height: mm(TRIM_H), dpi: 150,
    margins: { top: mm(TOP), bottom: mm(BOTTOM), left: mm(INNER), right: mm(OUTER),
      mirror: true } },
  layout: { layoutType: 'double', gutterWidth: mm(GUTTER) },
  bodyText: { fontFamily: SERIF, fontSize: pt(9.4), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    textAlign: 'justify', firstLineIndent: mm(4), indentAfterHeading: false,
    hyphenation: { enabled: true }, optimalLineBreaking: true,
    avoidWidows: true, avoidOrphans: true, avoidRunts: true },
  headings: { fontFamily: SANS, color: col('accent'), fontWeight: 800, levels: [
    { level: 1, breakBefore: { enabled: true, parity: 'any' } }, // gotcha: headings-drop-h1-break
    { level: 2, ...sans(11.5, 800), lineHeight: pt(LEAD), marginTop: pt(LEAD),
      marginBottom: pt(0) },
    { level: 3, ...sans(9.4, 700), color: col('ink'), lineHeight: pt(LEAD),
      marginTop: pt(LEAD / 2), marginBottom: pt(0) },
    { level: 4, fontFamily: SERIF, fontSize: pt(9.4), fontWeight: 700, italic: true,
      color: col('ink'), lineHeight: pt(LEAD), marginTop: pt(LEAD / 2), marginBottom: pt(0) },
  ] },
  unorderedLists: { bulletChar: '•', color: col('accent'), marginTop: pt(0),
    marginBottom: pt(0) },
  paragraphStyles: [
    small('abbr', 8, 11, { spaceBetween: pt(0), boldColor: col('accent'), boldFontWeight: 800 }),
    small('colophon', 7, 9.6, { color: col('muted'), spaceBetween: pt(3) }),
  ],
  tableStyle: { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
    headerBackground: col('accent'), headerColor: col('paper'), headerBold: true,
    headerFontFamily: SANS, headerFontSize: pt(7.4), bodyFontFamily: SANS,
    bodyFontSize: pt(7.5), bodyColor: col('ink'), cellPadding: mm(0.45) },
  captionStyle: { fontFamily: SANS, fontSize: pt(7.8), color: col('ink'), labelBold: true,
    labelColor: col('accent'), gap: mm(2), note: { fontSize: pt(6.9), color: col('muted') } },
});

// ─── 2 · Content ────────────────────────────────────────────────────────────
const markdown = String.raw`---
Markdown样例 · 102行 · content.en.mdtitle: "Delivering Cognitive Behavior Therapy to Young Adults With Symptoms of Depression and Anxiety Using a Fully Automated Conversational Agent (Woebot): A Randomized Controlled Trial" author: "Kathleen Kara Fitzpatrick, Alison Darcy and Molly Vierhile" --- # Delivering Cognitive Behavior Therapy to Young Adults With Symptoms of Depression and Anxiety Using a Fully Automated Conversational Agent (Woebot): A Randomized Controlled Trial {style="article" kind="Randomized controlled trial · Digital mental health" authors="Kathleen Kara Fitzpatrick, PhD^1^\*, Alison Darcy, PhD^2^\*, Molly Vierhile, BA^1^" affiliations="^1^ Stanford School of Medicine, Department of Psychiatry and Behavioral Sciences, Stanford, CA, United States\n^2^ Woebot Labs Inc., San Francisco, CA, United States\n\* Contributed equally. Corresponding author: Alison Darcy, PhD" history="Received 29 March 2017 · Revised 5 May 2017 · Accepted 22 May 2017 · Published 6 June 2017" source="Abridged from JMIR Mental Health 2017;4(2):e19, doi:10.2196/mental.7785 · © the authors, CC BY 4.0"} :::callout{type="abstract" title="Abstract" span="page"} :::columns{count=2} **Background** Web-based cognitive-behavioral therapeutic (CBT) apps have demonstrated efficacy but are characterized by poor adherence. Conversational agents may offer a convenient, engaging way of getting support at any time. **Objective** The objective of the study was to determine the feasibility, acceptability, and preliminary efficacy of a fully automated conversational agent to deliver a self-help program for college students who self-identify as having symptoms of anxiety and depression. **Methods** In an unblinded trial, 70 individuals age 18-28 years were recruited online from a university community social media site and were randomized to receive either 2 weeks (up to 20 sessions) of self-help content derived from CBT principles in a conversational format with a text-based conversational agent (Woebot) (n=34) or were directed to the National Institute of Mental Health ebook, “Depression in College Students,” as an information-only control group (n=36). All participants completed Web-based versions of the 9-item Patient Health Questionnaire (PHQ-9), the 7-item Generalized Anxiety Disorder scale (GAD-7), and the Positive and Negative Affect Scale at baseline and 2-3 weeks later (T2). **Results** Participants were on average 22.2 years old (SD 2.33), 67% female (47/70), mostly non-Hispanic (93%, 54/58), and Caucasian (79%, 46/58). Participants in the Woebot group engaged with the conversational agent an average of 12.14 (SD 2.23) times over the study period. No significant differences existed between the groups at baseline, and 83% (58/70) of participants provided data at T2 (17% attrition). Intent-to-treat univariate analysis of covariance revealed a significant group difference on depression such that those in the Woebot group significantly reduced their symptoms of depression over the study period as measured by the PHQ-9 (*F*=6.47; *P*=.01) while those in the information control group did not. In an analysis of completers, participants in both groups significantly reduced anxiety as measured by the GAD-7 (*F*~1,54~= 9.24; *P*=.004). Participants’ comments suggest that process factors were more influential on their acceptability of the program than content factors mirroring traditional therapy. **Conclusions** Conversational agents appear to be a feasible, engaging, and effective way to deliver CBT. ::: :::space{lines=1} **Keywords** conversational agents; mobile mental health; mental health; chatbots; depression; anxiety; college students; digital health **Trial registration** None. The trial involved a nonclinical population of college students and was considered exempt from registration in a public trials registry; it is reported with the CONSORT-EHEALTH checklist. ::: ## Introduction Up to 74% of mental health diagnoses have their first onset before the age of 24 [@kessler2007]. Depression and anxiety symptoms are particularly common among college students, with more than half reporting symptoms of anxiety and depression in the previous year that were so severe they had difficulty functioning [@zivin2009]. In addition, epidemiological data suggest that mental health problems are both increasing in prevalence and severity [@hunt2010]. However, up to 75% of the college students that need them do not access clinical services [@hunt2010]. While the reasons for this are varied, the ubiquity of free or inexpensive mental health services on campuses suggests that service availability and cost are not primary barriers to care [@hunt2010]. Like non-college populations, stigma is considered the primary barrier to accessing psychological health services. Overcoming problems of stigma has been traditionally considered a major benefit of Internet-delivered and more recently mobile mental health interventions. In recent years, there has been an explosion of interest and development of such services to either supplement existing mental health treatments or expand limited access to quality mental health services [@bakker2016]. This development is matched by great patient demand with about 70% showing interest in using mobile apps to self-monitor and self-manage their mental health [@torous2014]. Internet interventions for anxiety and depression have empirical support [@spek2007] with outcomes comparable to therapist-delivered cognitive behavioral therapy (CBT) [@barak2008; @andersson2009]. Yet, despite demonstrated efficacy, they are characterized by relatively poor adoption and adherence. One review found a median minimal completion rate of 56% [@donkin2013]. A hypothesized reason for this lack of adherence is the loss of the human interactional quality that in-person CBT retains. With recent advancements in voice recognition, conversational interfaces (ie, those that use natural language as inputs and outputs) have begun to emerge. Conversational agents (such as Apple’s Siri or Amazon’s Alexa) may be a more natural medium through which individuals engage with technology. Humans respond and converse with nonhuman agents in ways that mirror emotional and social discourse dynamics when discussing behavioral health [@bickmore2005] and their capacity to act as first responders has already been evaluated [@miner2016]. Theoretically, conversational interfaces may be better positioned than visually oriented mobile apps to deliver structured, manualized therapies because in addition to delivering therapeutic content, they can mirror therapeutic process. Indeed, @bickmore2005 demonstrated that a carefully designed health-related conversational agent could establish a therapeutic relationship with adults attempting to increase exercise. The intervention was an embodied conversational agent, that is, it was designed with a graphical face to mirror human interactions that are typically face-to-face. Thus, the objective of this study was to assess the feasibility of delivering CBT in a conversational interface via an automated bot in a way that facilitates engagement and reduction in symptoms. The current study compared outcomes from 2 weeks of a CBT-oriented conversational agent (Woebot), or an information control group (National Institute of Mental Health’s [NIMH] ebook) in a nonclinical college population. We hypothesized that conversation with a therapeutic process-oriented conversational agent would lead to greater improvement in symptoms relative to the information control group. We also hypothesized that receiving psychoeducational material in a conversational manner would be more acceptable to those who received it. ## Methods ### Recruitment and Procedure Potential participants were recruited using a flyer posted on social media websites targeting a US university community for students who self-identified as experiencing symptoms of depression and anxiety. Inclusion criteria included age 18 and over (screened at the first level via checkbox confirmation) and able to read English (implied). To guard against compromise, for example from malicious bots, all potential participants were sent an email requesting that they respond denoting their confirmation. Confirmed participants were randomized via computer algorithm that automatically generated a number between 0 and 1. Participants with numbers <0.5 were allocated to receive a direct link to begin chatting with Woebot in an instant messenger app, and participants with numbers >0.5 were sent a link to NIMH’s ebook on depression among college students [@nimh2017], after completion of online baseline questionnaires. Because the randomization allocation occurred algorithmically, allocation concealment was in place. However, the condition to which each participant was allocated was not masked for the service providers (Woebot Labs). After approximately 2 weeks (T2), participants were contacted again to complete a second set of questionnaires online. Participants were offered a prorated incentive of US \$10 per completed assessment (US \$20 for completion of both assessments). Since this trial involved a nonclinical population of college students, it was considered exempt from registration in a public trials registry. See Multimedia Appendix 1 for the study’s CONSORT-EHEALTH checklist [@eysenbach2011]. ### Woebot Woebot is an automated conversational agent designed to deliver CBT in the format of brief, daily conversations and mood tracking. Woebot is used within an instant messenger app that is platform agnostic and can be used either on a desktop or mobile device. Each interaction begins with a general inquiry about context (eg, “What’s going on in your world right now?”), and mood (eg, “How are you feeling?”) with responses provided as word or emoji images to represent affect in that moment. After gathering mood data, participants are presented with core concepts related to CBT by link to short video, or by way of short “word games” designed to facilitate teaching participants about cognitive distortions. The first day included an “onboarding” process that introduced the bot, adding that while the bot may seem like a person, it is closer to a “choose your own adventure self-help book” and therefore not fully capable of understanding what the needs of the user may be. The bot also briefly explained CBT and notified the user that while a psychologist was “keeping an eye on things” (ie, monitoring), this was not happening in real time and thus the service should not be used as a replacement for therapy. In addition, participants were encouraged to call 911 for emergencies. The bot’s conversational style was modeled on human clinical decision making and the dynamics of social discourse. Psychoeducational content was adapted from self-help for CBT [@burns1980; @burns2006; @towery2016]. Aside from CBT content, the bot was created to include the following therapeutic process-oriented features: - **Empathic responses:** The bot replied in an empathic way appropriate to the participants’ inputted mood. - **Tailoring:** Specific content is sent to individuals depending on mood state. For example, a participant indicating that they feel anxious is offered in-vivo assistance with the anxious event. - **Goal setting:** The conversational agent asked participants if they had a personal goal that they hoped to achieve over the 2-week period. - **Accountability:** To facilitate a sense of accountability, the bot set expectations of regular check-ins and followed up on earlier activities, for example, on the status of the stated goal. - **Motivation and engagement:** To engage the individual in daily monitoring, the bot sent one personalized message every day or every other day to initiate a conversation (ie, prompting). - **Reflection:** The bot also provided weekly charts depicting each participant’s mood over time. Each graph was sent with a brief description of the data to facilitate reflection. :::callout{type="chat" title="The bot’s messages quoted in the Methods"} :::callout{type="bubble" title="Check-in · context"} What’s going on in your world right now? ::: :::callout{type="bubble" title="Check-in · mood"} How are you feeling? ::: :::callout{type="bubble" title="Empathic response · endorsed loneliness"} I’m so sorry you’re feeling lonely. I guess we all feel a little lonely sometimes ::: :::callout{type="bubble" title="Empathic response · excitement"} Yay, always good to hear that! ::: :::callout{type="bubble" title="Reflection · weekly mood chart"} Overall, your mood has been fairly steady, though you tend to become tired after periods of anxiety. It looks like Tuesday was your best day. ::: ::: ### Information Control Condition In the information control condition, participants were directed to the NIMH resources section and specifically, a free publication entitled “Depression in College Students” [@nimh2017]. ### Measures #### The Patient Health Questionnaire-9 The Patient Health Questionnaire (PHQ-9) [@kroenke2001] is a 9-item, self-report questionnaire that assesses the frequency and severity of depressive symptomatology within the previous 2 weeks. Each of the 9 items is based on the Diagnostic and Statistical Manual of Mental Disorders, 4th edition (DSM-IV) criteria for major depressive disorder and can be scored on a 0 (not at all) to 3 (nearly every day) scale. #### Generalized Anxiety Disorder-7 The Generalized Anxiety Disorder 7-item scale (GAD-7) [@spitzer2006] is a valid, brief self-report tool to assess the frequency and severity of anxious thoughts and behaviors over the past 2 weeks. Based on the DSM-IV diagnostic criteria for GAD, the scores of all 7 items range from 0 (not at all) to 3 (nearly every day). Therefore, the total score ranges from 0-21. #### Positive and Negative Affect Schedule The Positive and Negative Affect Schedule (PANAS) [@watson1988] is a 20-item self-report measure of current positive and negative affect. Items are scored on a 1 (very slightly or not at all) to 5 (extremely) scale, with higher scores representing higher affect. Positive and negative affect are summed independent of each other with possible scores from 10-50. ### Statistical Analysis Statistical power calculations using analysis of covariance (ANCOVA) revealed that a sample size of 70 would have sufficient (80%) power to detect a moderate-large effect size (Cohen *d*=0.4) for depression, reported by a meta-analysis of Internet-delivered treatments for adult depression and anxiety [@andersson2009], with alpha at 5%. To determine whether any significant differences between groups existed at baseline, independent *t* tests were conducted on continuous baseline variables (eg, age, PHQ-9, GAD-7, and PANAS), and chi-square analyses were conducted on categorical or nominal variables (gender, race, ethnicity). Univariate effects of group membership on T2 outcomes were examined using between-subjects ANCOVA adjusting for baseline measures. Cohen *d* effect sizes were calculated to examine the magnitude of between-group differences. All subjects were included in intention-to-treat (ITT) analyses. Prior to conducting these analyses, the multiple imputation procedure in SPSS v. 23 was used to handle missing data assumed to be missing at random. As secondary subgroup analyses, we conducted completer analyses using 2x2 repeated measures analysis of variance (ANOVA) to explore main and interaction effects. ### Ethics and Informed Consent The study was reviewed and approved by Stanford School of Medicine’s Institutional Review Board. Participants indicated their consent to the terms of the study via checkbox on an information sheet. As additional safety measures, participants in the Woebot group who denoted long-standing depression, suicidality, or self-harm were automatically provided with helpline numbers and a crisis text line number, and were encouraged to call 911 in emergencies.
`; // title, abstract, Introduction, Methods const results = String.raw`## Results
Markdown样例 · 88行 · content.results.en.md :ref{id="fig-consort" style="full"} shows the participant flow throughout the study. A total of 204 registrations were received between January 31 and February 20, 2017, and all registrants were asked to confirm their interest by return email. A total of 115 responded to this email, though 45 of these were deemed bot-generated (eg, email addresses with unusual almost identical formats and identical responses) and were deemed ineligible. The resultant sample of N=70 were randomized via computer algorithm to receive either a direct link to begin chatting with Woebot (n=34) in an instant messenger app, or NIMH’s ebook on depression among college students [@nimh2017] (n=36), after completion of online questionnaires at baseline. ### Attrition Of the randomized participants, 83% (58/70) went on to provide partial or complete data at T2 representing an overall attrition rate of 17%. Attrition was not equal between the arms and was greater among the information control group (31% vs 9%; chi-square~1~=5.16; *P*=.023). However, independent *t* tests and chi-square analyses failed to detect evidence of significant differences at baseline between those who dropped out of the study versus those who did not on age (*t*~68~=1.18; *P*=.24); GAD-7 (*t*~68~=1.28; *P*=.89); PHQ-9 (*t*~68~=.63; *P*=.59); PANAS positive (*t*~68~=.79; *P*=.43) and negative (*t*~68~=.02; *P*=.98) affect scores; or on gender (chi-square~1~=1.75; *P*=.18) or ethnicity (chi-square~1~=.066; *P*=.79). ### Participant Demographics :ref{id="tbl-baseline" style="full"} shows the demographic information and baseline scores on clinical variables for those with data from the entire sample (N=58). Participants were an average of 22.2 years old (SD 2.33) and over two-thirds female. Participants were mostly non-Hispanic (93%, 54/58), 79% Caucasian (46/58), with 7% (4/58) Asian, 9% (5/58) more than one race, 2% (2/58) African American, and 2% (2/58) Native American/Alaskan Native. In terms of baseline characteristics, nearly half (46%, 32/69) of the sample was in the moderately-severe or severe range of depression at baseline as measured by the PHQ-9, while three-quarters (74%, 52/70) were in the severe range for anxiety as measured by the GAD-7. ### Preliminary Efficacy :ref{id="tbl-itt" style="full"} shows the results of the primary ITT analyses conducted on the entire sample. Univariate ANCOVA revealed a significant treatment effect on depression revealing that those in the Woebot group significantly reduced PHQ-9 score while those in the information control group did not (*F*~1,48~=6.03; *P*=.017). This represented a moderate between-groups effect size (*d*=0.44). This effect is robust after Bonferroni correction for multiple comparisons (*P*=.04). No other significant between-group differences were observed on anxiety or affect. ### Completer Analysis As a secondary analysis, to explore whether any main effects existed, 2x2 repeated measures ANOVAs were conducted on the primary outcome variables (with the exception of PHQ-9) among completers only. A significant main effect was observed on GAD-7 (*F*~1,54~=9.24; *P*=.004) suggesting that completers experienced a significant reduction in symptoms of anxiety between baseline and T2, regardless of the group to which they were assigned with a within-subjects effect size of *d*=0.37. No main effects were observed for positive (*F*~1,50~=.001; *P*=.951; *d*=0.21) or negative affect (*F*~1,50~=.06; *P*=.80; *d*=0.003) as measured by the PANAS. ### Use and Acceptability Participants in the Woebot condition checked in with the bot (defined as at least providing context and mood information) an average of 12.14 times (SD 2.23; median 12; range 8-18) over the 2-week period, with almost all check-ins occurring on unique days. While ratings indicated that both conditions were acceptable (above 3/5), participants in the Woebot condition reported significantly higher levels of satisfaction both overall (4.3 versus 3.4; *t*~48~=3.99; *P*<.001) and with content (4.0 versus 3.4; *t*~48~=2.30; *P*=.02), and they reported a significantly greater amount of emotional awareness as a result of using the bot (3.3 versus 2.7; *t*~47.06~=2.38; *P*=.021) than the information control group. ### Qualitative Results :ref{id="fig-best" style="full"} shows a thematic map of participants’ responses to the question “What was the best thing about your experience using Woebot?” Two major themes emerged in respect to this question: process and content. In the process theme, the subthemes that emerged were accountability from daily check-ins (noted by 9 participants); the empathy that the bot showed, or other factors relating to his “personality” (n=7); and the learning that the bot facilitated (n=12), which in turn was divided into further subthemes of emotional insight (n=5), general insight (n=5), and insights about cognitions (n=2). :ref{id="fig-worst" style="full"} illustrates a thematic map of participants’ responses to the question: “What was the worst thing about your experience with Woebot?” Three themes emerged: process violations (n=15), technical problems (n=8), and problems with content (n=8). By far the most common subtheme to emerge among the process violations related to the limitations in natural conversation such as the bot not being able to understand some responses or getting confused when unexpected answers were provided by participants (n=10), and 2 individuals noted that the conversations could get repetitive. ## Discussion ### Principal Results To our knowledge this is the first randomized trial of a nonembodied text-based conversational agent designed for therapeutic use. The objective of the study was to explore whether a fully automated conversational agent based on CBT principals could deliver a therapeutic experience to college students over a 2-week period. The study confirmed that after 2 weeks, those in the Woebot group experienced a significant reduction in depression, thus our hypothesis was partially supported. Woebot was associated with a high level of engagement with most individuals using the bot nearly every day and was generally viewed more favorably than the information-only comparison. ### Limitations There are several methodological weaknesses that limit the generalizability of the findings. As a feasibility study, we recruited a limited number of participants to receive a relatively short intervention, and no follow-up data were available to assess whether gains were sustained. The small number of participants meant that a formal mediator analysis was not possible, thus we cannot formally test a theorized relationship between engagement and outcome in this context of conversational agents. The study should be replicated with more participants, a longer dose, and a follow-up period to investigate if findings persist. Nonetheless, the relatively strong comparison group can be viewed as a strength of the study. Indeed, the relative strength of the control group was illustrated by the fact that individuals providing data in that group saw a similar reduction in anxiety as those who received Woebot, which supports the literature that suggests minimal passive psychoeducation alone can reduce symptoms of psychological distress [@donker2009]. Nonetheless, the choice of control group was somewhat limiting for two main reasons. First, it may have contributed to the high attrition rate since an ebook is not designed for multiple or recurring sessions. It also did not introduce any CBT-specific material, thus it was not possible to evaluate whether the conversational delivery mediated symptom reduction, rather than the CBT content that the bot delivered. Finally, the study was conducted in a New York area university community population and since we did not formally assess digital divide factors such as socioeconomic status, findings may be limited in their generalizability. ### Conclusions While results should be viewed with some caution and the findings need to be replicated, this study nonetheless demonstrates that a text-based conversational agent designed to mirror therapeutic process has the potential to offer an alternative and engaging method of delivering CBT for some 10 million college students in the United States who experience debilitating anxiety and depression. ## Conflicts of Interest {style="back"} The second author (AMD) is the founder of a commercial entity Woebot Labs Inc. (formerly, the Life Ninja Project) that created the intervention (Woebot) that is the subject of this trial and therefore has financial interest in that company. Woebot Labs Inc. covered the cost of participant incentives, though Standford [sic] made the payments. ## Abbreviations {style="back"} :::paragraphs{style="abbr"} **ANCOVA** analysis of covariance **ANOVA** analysis of variance **DSM-IV** Diagnostic and Statistical Manual of Mental Disorders, 4th edition **GAD-7** Generalized Anxiety Disorders scale **ITT** intention to treat **NIMH** National Institute of Mental Health **PANAS** Positive and Negative Affect Scale **PHQ-9** Patient Health Questionnaire scale **T2** time 2 ::: ## References {style="back"} :::bibliography{title=""} ## About This Edition {style="back"} :::paragraphs{style="colophon"} Abridged from Fitzpatrick KK, Darcy A, Vierhile M. Delivering Cognitive Behavior Therapy to Young Adults With Symptoms of Depression and Anxiety Using a Fully Automated Conversational Agent (Woebot): A Randomized Controlled Trial. JMIR Mental Health 2017;4(2):e19. doi:10.2196/mental.7785. © Kathleen Kara Fitzpatrick, Alison Darcy, Molly Vierhile. Originally published in JMIR Mental Health (http://mental.jmir.org), 06.06.2017. This is an open-access article distributed under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work, first published in JMIR Mental Health, is properly cited. Changes: sections, paragraphs and sentences cut; the original Figure 2 and Multimedia Appendix 1 left out; citations converted from numbered to APA author–date; Figure 1 redrawn as a CONSORT diagram and Figures 3 and 4 redrawn as bar charts (Figures 2 and 3 here); the bot’s quoted messages gathered in a box; the chi-square symbol spelled out. Set in Lora and Nunito Sans (SIL OFL) for the Postext Cookbook. :::
`; // Results, Discussion, back matter const references = String.raw`:::references{format=bibtex}
Markdown样例 · 94行 · content.references.en.md@article{kessler2007, author = {Kessler, Ronald C. and Amminger, G. Paul and Aguilar-Gaxiola, Sergio and Alonso, Jordi and Lee, Sing and {\"U}st{\"u}n, T. Bedirhan}, title = {Age of onset of mental disorders: a review of recent literature}, journal = {Current Opinion in Psychiatry}, year = 2007, volume = 20, number = 4, pages = {359--364}, doi = {10.1097/YCO.0b013e32816ebc8c}} @article{zivin2009, author = {Zivin, Kara and Eisenberg, Daniel and Gollust, Sarah E. and Golberstein, Ezra}, title = {Persistence of mental health problems and needs in a college student population}, journal = {Journal of Affective Disorders}, year = 2009, volume = 117, number = 3, pages = {180--185}, doi = {10.1016/j.jad.2009.01.001}} @article{hunt2010, author = {Hunt, Justin and Eisenberg, Daniel}, title = {Mental health problems and help-seeking behavior among college students}, journal = {Journal of Adolescent Health}, year = 2010, volume = 46, number = 1, pages = {3--10}, doi = {10.1016/j.jadohealth.2009.08.008}} @article{bakker2016, author = {Bakker, David and Kazantzis, Nikolaos and Rickwood, Debra and Rickard, Nikki}, title = {Mental Health Smartphone Apps: Review and Evidence-Based Recommendations for Future Developments}, journal = {JMIR Mental Health}, year = 2016, volume = 3, number = 1, pages = {e7}, doi = {10.2196/mental.4984}} @article{torous2014, author = {Torous, John and Chan, Steven Richard and Yee-Marie Tan, Shih and Behrens, Jacob and Mathew, Ian and Conrad, Erich J. and Hinton, Ladson and Yellowlees, Peter and Keshavan, Matcheri}, title = {Patient Smartphone Ownership and Interest in Mobile Apps to Monitor Symptoms of Mental Health Conditions: A Survey in Four Geographically Distinct Psychiatric Clinics}, journal = {JMIR Mental Health}, year = 2014, volume = 1, number = 1, pages = {e5}, doi = {10.2196/mental.4004}} @article{spek2007, author = {Spek, Viola and Cuijpers, Pim and Nyklícek, Ivan and Riper, Heleen and Keyzer, Jules and Pop, Victor}, title = {Internet-based cognitive behaviour therapy for symptoms of depression and anxiety: a meta-analysis}, journal = {Psychological Medicine}, year = 2007, volume = 37, number = 3, pages = {319--328}, doi = {10.1017/S0033291706008944}} @article{barak2008, author = {Barak, Azy and Hen, Liat and Boniel-Nissim, Meyran and Shapira, Na'ama}, title = {A Comprehensive Review and a Meta-Analysis of the Effectiveness of Internet-Based Psychotherapeutic Interventions}, journal = {Journal of Technology in Human Services}, year = 2008, volume = 26, number = {2--4}, pages = {109--160}, doi = {10.1080/15228830802094429}} @article{andersson2009, author = {Andersson, Gerhard and Cuijpers, Pim}, title = {Internet-based and other computerized psychological treatments for adult depression: a meta-analysis}, journal = {Cognitive Behaviour Therapy}, year = 2009, volume = 38, number = 4, pages = {196--205}, doi = {10.1080/16506070903318960}} @article{donkin2013, author = {Donkin, Liesje and Hickie, Ian B. and Christensen, Helen and Naismith, Sharon L. and Neal, Bruce and Cockayne, Nicole L. and Glozier, Nick}, title = {Rethinking the dose-response relationship between usage and outcome in an online intervention for depression: randomized controlled trial}, journal = {Journal of Medical Internet Research}, year = 2013, volume = 15, number = 10, pages = {e231}, doi = {10.2196/jmir.2771}} @article{bickmore2005, author = {Bickmore, Timothy and Gruber, Amanda and Picard, Rosalind}, title = {Establishing the computer-patient working alliance in automated health behavior change interventions}, journal = {Patient Education and Counseling}, year = 2005, volume = 59, number = 1, pages = {21--30}, doi = {10.1016/j.pec.2004.09.008}} @article{miner2016, author = {Miner, Adam S. and Milstein, Arnold and Schueller, Stephen and Hegde, Roshini and Mangurian, Christina and Linos, Eleni}, title = {Smartphone-Based Conversational Agents and Responses to Questions About Mental Health, Interpersonal Violence, and Physical Health}, journal = {JAMA Internal Medicine}, year = 2016, volume = 176, number = 5, pages = {619--625}, doi = {10.1001/jamainternmed.2016.0400}} @online{nimh2017, author = {{National Institute of Mental Health}}, title = {Depression in college students}, year = 2017, urldate = {2017-03-29}, url = {https://www.nimh.nih.gov/health/publications/depression-and-college-students/index.shtml}} @article{eysenbach2011, author = {Eysenbach, Gunther and {CONSORT-EHEALTH Group}}, title = {CONSORT-EHEALTH: Improving and Standardizing Evaluation Reports of Web-based and Mobile Health Interventions}, journal = {Journal of Medical Internet Research}, year = 2011, volume = 13, number = 4, pages = {e126}, doi = {10.2196/jmir.1923}} @book{burns1980, author = {Burns, David D.}, title = {Feeling good: The new mood therapy}, publisher = {Harper Collins}, address = {New York}, year = 1980} @book{burns2006, author = {Burns, David D.}, title = {When panic attacks}, publisher = {Harmony}, address = {New York}, year = 2006} @book{towery2016, author = {Towery, Jacob}, title = {The anti-depressant book: A practical guide for teens and young adults to overcome depression and stay healthy}, publisher = {Jacob Towery}, address = {Palo Alto, CA}, year = 2016} @article{kroenke2001, author = {Kroenke, Kurt and Spitzer, Robert L. and Williams, Janet B. W.}, title = {The PHQ-9: validity of a brief depression severity measure}, journal = {Journal of General Internal Medicine}, year = 2001, volume = 16, number = 9, pages = {606--613}, doi = {10.1046/j.1525-1497.2001.016009606.x}} @article{spitzer2006, author = {Spitzer, Robert L. and Kroenke, Kurt and Williams, Janet B. W. and Löwe, Bernd}, title = {A brief measure for assessing generalized anxiety disorder: the GAD-7}, journal = {Archives of Internal Medicine}, year = 2006, volume = 166, number = 10, pages = {1092--1097}, doi = {10.1001/archinte.166.10.1092}} @article{watson1988, author = {Watson, David and Clark, Lee Anna and Tellegen, Auke}, title = {Development and validation of brief measures of positive and negative affect: the PANAS scales}, journal = {Journal of Personality and Social Psychology}, year = 1988, volume = 54, number = 6, pages = {1063--1070}, doi = {10.1037//0022-3514.54.6.1063}} @article{donker2009, author = {Donker, Tara and Griffiths, Kathleen M. and Cuijpers, Pim and Christensen, Helen}, title = {Psychoeducation for depression, anxiety and psychological distress: a meta-analysis}, journal = {BMC Medicine}, year = 2009, volume = 7, pages = {79}, doi = {10.1186/1741-7015-7-79}} :::
`; // the BibTeX of the works the text cites // #region tables: Tables 1 and 2, means and their spread in columns of their own // Nunito Sans sets tabular figures, so numbers right-aligned in a column line up on the // decimal point; the (SD) or (SE) sits in a column of its own, flush left beside it. // aligns: one letter per column, l or r; header cells over the numbers are centred. const cell = (content, align, head) => ({ content, ...(head && { isHeader: true }), align: head && align !== 'left' ? 'center' : align }); function grid(rows, widths, aligns, heads, spans) { // spans: [row, col, lastRow, lastCol] const a = [...aligns].map((k, c) => (c && k === 'r' ? 'right' : 'left')); let m = { headerRowCount: heads, columnWidths: widths, rows: rows.map((row, r) => widths.map((_, c) => cell(row[c] ?? '', a[c], r < heads))) }; for (const [r0, c0, r1, c1] of spans) { m = mergeCells(m, { start: { row: r0, col: c0 }, end: { row: r1, col: c1 } }); } return m; // mergeCells marks the covered cells hiddenBy (gotcha: merged-cells-hiddenby) } const pair = (s) => s.split(' '); // '13.25 (5.17)' → ['13.25', '(5.17)'] const BASE = [['Depression (PHQ-9)', '13.25 (5.17)', '14.30 (6.65)'], ['Anxiety (GAD-7)', '19.02 (4.27)', '18.05 (5.89)'], ['Positive affect', '26.19 (8.37)', '25.54 (9.58)'], ['Negative affect', '28.74 (8.92)', '24.87 (8.13)'], ['Age, mean (SD)', '21.83 (2.24)', '22.58 (2.38)'], ['**Gender, n (%)**'], ['Male', '4 (7)', '7 (21)'], ['Female', '20 (55)', '27 (79)'], ['**Ethnicity, n (%)**'], ['Latino/Hispanic', '2 (8)', '2 (6)'], ['Non-Latino/Hispanic', '22 (92)', '32 (94)'], ['Caucasian', '18 (75)', '28 (82)'], ['Non-Caucasian', '6 (25)', '6 (18)']]; const ITT = [['PHQ-9', '13.67 (.81)', '12.07-15.27', '11.14 (0.71)', '9.74-12.32', '6.03', '.017', '0.44'], ['GAD-7', '16.84 (.67)', '15.52-18.56', '17.35 (0.60)', '16.16-18.13', '0.38', '.581', '0.14'], ['PANAS positive affect', '26.02 (1.45)', '23.17-28.86', '26.88 (1.29)', '24.35-29.41', '0.17', '.707', '0.02'], ['PANAS negative affect', '27.53 (1.42)', '24.73-30.32', '25.98 (1.24)', '23.54-28.42', '0.91', '.912', '0.344']]; const table = (id, model, span, caption, note) => ({ id, typeId: 'table', kind: 'table', createdAt: 0, updatedAt: 0, placement: { position: 'top', span }, caption, note, table: { model } }); const baseline = grid([['', 'Information control', '', 'Woebot', ''], ['**Scale, mean (SD)**'], ...BASE.map(([k, a, b]) => (a ? [k, ...pair(a), ...pair(b)] : [k]))], [26, 13, 10, 13, 10], 'lrlrl', 1, [[0, 1, 0, 2], [0, 3, 0, 4], [1, 0, 1, 4], [7, 0, 7, 4], [10, 0, 10, 4]]); const itt = grid([['', 'Information-only control', '', '', 'Woebot', '', '', '*F*', '*P*', '*d*^c^'], ['', 'T2^a^', '', '95% CI^b^', 'T2^a^', '', '95% CI^b^', '', '', ''], ...ITT.map(([k, a, ca, b, cb, ...s]) => [k, ...pair(a), ca, ...pair(b), cb, ...s])], [30, 10, 9, 18, 10, 9, 18, 8, 8, 8], 'lrlrrlrrrr', 2, [[0, 0, 1, 0], [0, 1, 0, 3], [0, 4, 0, 6], [1, 1, 1, 2], [1, 4, 1, 5], [0, 7, 1, 7], [0, 8, 1, 8], [0, 9, 1, 9]]); const resources = () => [consort, table('tbl-baseline', baseline, 'column', 'Demographic and clinical variables of ' + 'participants at baseline.', 'Participants with data at T2 (N=58), as printed in the ' + 'original Table 1.'), table('tbl-itt', itt, 'page', 'Results of ITT analysis of entire sample on primary outcomes ' + 'in the study at T2.', '^a^Baseline=pooled mean (standard error). ^b^95% confidence ' + 'interval. ^c^Cohen *d* shown for between-subjects effects using means and standard ' + 'errors at Time 2.'), ...THEMES.map(({ id, file, caption, note, alt }) => ({ id, typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0, placement: { position: 'auto' }, caption, note, altText: alt, svg: { fileId: file, width: 845, height: Math.round(themeHeight(id) * 10) } })), ]; // #endregion // #region art: the CONSORT diagram and the theme charts, their labels in Nunito Sans inline const n2 = (v) => +v.toFixed(2); const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;'); // An SVG drawn as an image cannot see the page's web fonts (gotcha: svg-no-webfonts), so each // drawing carries its faces inline, as data URLs of the Fontsource files. async function inlineFaces(family, weights) { const id = family.toLowerCase().replace(/\s+/g, '-'); let css = ''; for (const w of weights) { const url = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@5/files/${id}-latin-${w}` + '-normal.woff2'; const bytes = new Uint8Array(await (await fetch(url)).arrayBuffer()); let bin = ''; for (const b of bytes) bin += String.fromCharCode(b); css += `@font-face{font-family:F;font-weight:${w};src:url(data:font/woff2;base64,` + `${btoa(bin)}) format('woff2')}`; } return `<style>${css}text{font-family:F}</style>`; } const label = (x, y, s, size, weight, fill, anchor = 'middle') => `<text x="${n2(x)}" ` + `y="${n2(y)}" font-size="${size}" font-weight="${weight}" fill="${fill}" ` + `text-anchor="${anchor}">${esc(s)}</text>`; // A box of centred lines: the first bold, an "n = …" line bold in the accent (white on a // filled box), the rest regular. Every box is 64, 56 or 26 mm wide; lines 1.3 × the size. function node(cx, y, w, lines, { size = 2.6, fill = palette.tint, stroke = palette.accent } = {}) { const lh = size * 1.3; const h = lines.length * lh + 2.2; const solid = fill === palette.accent; let svg = `<rect x="${n2(cx - w / 2)}" y="${n2(y)}" width="${w}" height="${n2(h)}" rx="1.2" ` + `fill="${fill}" stroke="${stroke}" stroke-width="0.3"/>`; lines.forEach((s, i) => { const isN = /^n = /.test(s); svg += label(cx, y + 1.1 + lh * (i + 0.78), s, size, i === 0 || isN ? 800 : 400, solid ? palette.paper : isN ? palette.accent : palette.ink); }); return { svg, h, top: y, bottom: y + h, mid: y + h / 2 }; } // Arrows are a line plus a filled triangle path: no <marker> (gotcha: svg-no-marker-filters). const line = (pts) => `<path d="M${pts.map(([x, y]) => `${n2(x)} ${n2(y)}`).join('L')}" ` + `fill="none" stroke="${palette.ink}" stroke-width="0.3"/>`; function arrow(pts) { const [[x0, y0], [x1, y1]] = pts.slice(-2); const a = Math.atan2(y1 - y0, x1 - x0); const p = (d, s) => `${n2(x1 - Math.cos(a) * d + Math.sin(a) * s)} ` + `${n2(y1 - Math.sin(a) * d - Math.cos(a) * s)}`; return line([...pts.slice(0, -1), [x1 - Math.cos(a) * 1.4, y1 - Math.sin(a) * 1.4]]) + `<path d="M${n2(x1)} ${n2(y1)}L${p(1.8, 0.9)}L${p(1.8, -0.9)}Z" fill="${palette.ink}"/>`; } // The four CONSORT stages as pills at the left edge, each centred on a y. const stage = (y, s) => `<rect x="0" y="${n2(y - 2.2)}" width="${n2(s.length * 1.9 + 5)}" ` + `height="4.4" rx="2.2" fill="${palette.ink}"/>` + label(2.5, y + 0.85, s.toUpperCase(), 2.3, 800, palette.paper, 'start'); function consortSvg(face) { // 176 mm wide, the full measure; one unit is a millimetre const [W, L, R, MID] = [176, 59, 117, 88]; const side = { size: 2.5, fill: palette.paper, stroke: palette.rule }; const a = node(MID, 0.5, 64, ['Registrations received by email', 'n = 204']); const b = node(MID, a.bottom + 3, 64, ['Responded to the email confirmation', 'n = 115']); const x = node(150, b.bottom + 0.5, 52, ['Excluded as ineligible', 'n = 45', 'deemed bot-generated'], side); const c = node(MID, x.bottom + 2, 64, ['Randomized by computer algorithm', 'n = 70'], { fill: palette.accent }); const split = c.bottom + 4; // the line that divides the sample between the arms const parts = [a.svg, b.svg, x.svg, c.svg, stage(a.mid, 'Enrollment'), arrow([[MID, a.bottom], [MID, b.top]]), arrow([[MID, b.bottom], [MID, c.top]]), arrow([[MID, x.mid], [124, x.mid]]), stage(split, 'Allocation'), line([[MID, c.bottom], [MID, split]]), line([[L, split], [R, split]])]; const arms = [[L, 13, 'Allocated to Woebot', 34, 'up to 20 sessions over 2 weeks', 3, 31], [R, 163, 'Allocated to information-only control', 36, 'NIMH ebook on depression', 11, 25]]; for (const [cx, sx, title, n, what, gone, kept] of arms) { const box = node(cx, split + 3.5, 56, [title, `n = ${n}`, what]); const lost = node(sx, box.bottom + 4.5, 26, ['Lost to follow-up', `n = ${gone}`], side); const t2 = node(cx, lost.bottom + 2, 56, ['Provided data at T2', `n = ${kept}`]); const an = node(cx, t2.bottom + 5.5, 56, ['Analysed (intention to treat)', `n = ${n}`, 'missing T2 data imputed'], { fill: palette.accent }); parts.push(box.svg, lost.svg, t2.svg, an.svg, arrow([[cx, split], [cx, box.top]]), arrow([[cx, box.bottom], [cx, t2.top]]), arrow([[cx, lost.mid], [sx + (sx < MID ? 13 : -13), lost.mid]]), arrow([[cx, t2.bottom], [cx, an.top]])); if (cx === R) parts.push(stage(lost.top - 3, 'Follow-up'), stage(t2.bottom + 2.75, 'Analysis')); } return `<svg xmlns="http://www.w3.org/2000/svg" width="1760" height="${CONSORT_H * 10}" ` + `viewBox="0 0 ${W} ${CONSORT_H}">${face}${parts.join('')}</svg>`; } // Figures 3 and 4 of the original are thematic maps; here they are bars, one per subtheme. const THEMES = [ { id: 'fig-best', file: 'best.svg', themes: [['Process', 31, [['Checking in / accountability', 9], ['Empathy / personality', 7], ['Learning', 12, [['Emotions', 5], ['General insight', 5], ['Cognitions', 2]]], ['Conversation', 3]]], ['Content', 16, [['Videos', 7], ['Games', 3], ['Suggestions', 2], ['Weekly graphs', 1]]]], caption: 'Best features of the Woebot experience: themes of the answers to “What was the best ' + 'thing about your experience using Woebot?”', note: 'Number of participants per theme. Redrawn as bars from the thematic map in Figure 3 of ' + 'the original; numbers as printed there.', alt: 'Bars for Process (31): checking in 9, empathy 7, learning 12 (emotions 5, general ' + 'insight 5, cognitions 2), conversation 3; Content (16): videos 7, games 3, suggestions 2, ' + 'weekly graphs 1.' }, { id: 'fig-worst', file: 'worst.svg', themes: [['Process violations', 15, [['Not being able to converse naturally', 10], ['Repetitive', 2], ['Miscellaneous', 3]]], ['Technical problems', 8, [['Glitches', 4], ['Looping', 4]]], ['Content', 8, [['Emoticons', 2], ['Interactions too short', 2], ['Videos too long', 2], ['Other', 2]]]], caption: 'Least favored experiences: themes of the answers to “What was the worst thing about ' + 'your experience of using Woebot?”', note: 'Number of participants per theme. Redrawn as bars from the thematic map in Figure 4 of ' + 'the original; numbers as printed there.', alt: 'Bars for Process violations (15): not conversing naturally 10, repetitive 2, ' + 'miscellaneous 3; Technical problems (8): glitches 4, looping 4; Content (8): emoticons, ' + 'short interactions, long videos and other, 2 each.' }, ]; const rows = (themes) => themes.flatMap(([name, n, subs]) => [{ name, n, depth: 0 }, ...subs.flatMap(([s, k, deeper = []]) => [{ name: s, n: k, depth: 1 }, ...deeper.map(([d, m]) => ({ name: d, n: m, depth: 2 }))])]); const ROW = 4.4; function themeHeight(id) { return rows(THEMES.find((f) => f.id === id).themes).length * ROW + 2; } function themeSvg({ id, themes }, face) { // 84.5 mm wide: one column const [W, X0, X1] = [84.5, 48, 79]; const H = themeHeight(id); let svg = ''; rows(themes).forEach(({ name, n, depth }, i) => { const y = 1 + i * ROW; if (!depth) { svg += `<path d="M0 ${n2(y + 0.2)}H${W}" stroke="${palette.rule}" stroke-width="0.25"/>` + label(0, y + 3.1, `${name} (${n})`, 2.75, 800, palette.ink, 'start'); return; } const w = (n / 12) * (X1 - X0); svg += label(depth * 3 - 1, y + 3, name, 2.45, 400, palette.ink, 'start') + `<rect x="${X0}" y="${n2(y + 0.9)}" width="${n2(w)}" height="2.6" ` + `fill="${depth === 1 ? palette.accent : palette.soft}"/>` + label(X0 + w + 1.2, y + 3, String(n), 2.55, 800, palette.ink, 'start'); }); return `<svg xmlns="http://www.w3.org/2000/svg" width="845" height="${Math.round(H * 10)}" ` + `viewBox="0 0 ${W} ${n2(H)}">${face}${svg}</svg>`; } // #endregion // ─── 3 · Fonts ────────────────────────────────────────────────────────────── const FONTS = { Lora: ['400', '400i', '700', '700i'], 'Nunito Sans': ['400', '400i', '600', '700', '800'] }; // ─── 4 · Build & show ─────────────────────────────────────────────────────── const paper = `${markdown}\n\n${results}\n\n${references}`; await loadFonts(FONTS, paper); const face = await inlineFaces(SANS, [400, 800]); await loadSvg('consort.svg', consortSvg(face)); for (const fig of THEMES) await loadSvg(fig.file, themeSvg(fig, face)); const content = { markdown: paper, resources: resources() }; const doc = await buildWithFonts(() => buildDocument(content, config()), paper); showPages(doc, { title: 'A clinical trial report with a CONSORT diagram' }); offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider, resourceBytes: imageBytes }), `${RECIPE}.pdf`);
工具包 · core, fonts, viewer, pdf, images:每道食谱都相同 · 310行// ─── Kit ── helpers shared by every Cookbook recipe · postext.dev/cookbook ───── // ─── Kit · core v1 ── the same in every recipe · postext.dev/cookbook ───────── function mm(value) { return { value, unit: 'mm' }; } function pt(value) { return { value, unit: 'pt' }; } function em(value) { return { value, unit: 'em' }; } /** The sample language's string: t({ en: 'Figure', es: 'Figura' }). */ function t(strings) { return strings[LANG] ?? Object.values(strings)[0]; } /** A file in this recipe's assets folder, served from the Postext repo by jsDelivr. */ function asset(file) { return `https://cdn.jsdelivr.net/gh/drnachio/postext@main/cookbook/${RECIPE}/assets/${file}`; } // ─── Kit · fonts v1 ── the same in every recipe · postext.dev/cookbook ──────── // Postext measures text with the faces the browser has loaded, and caches the // widths, so every face must be ready before the first build. Faces come from // Fontsource: the same static files the PDF embeds, so screen and PDF agree. /** faces = { 'Family Name': ['400', '400i', '700'] }. `text` is the sample: * letters beyond Latin-1 (č, ł, ő…) also load the latin-ext files. With * `optional`, a face Fontsource does not ship is skipped instead of failing. * Resolves to the number of faces added. */ async function loadFonts(faces, text = '', { optional = false } = {}) { kitStatus('Loading fonts…'); const ranges = { latin: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,' + 'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD', 'latin-ext': 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,' + 'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF', }; const subsets = /[Ā-˿Ḁ-ỿ]/.test(text) ? ['latin', 'latin-ext'] : ['latin']; const jobs = []; let added = 0; for (const [family, specs] of Object.entries(faces)) { const id = fontsourceId(family); const meta = optional ? await fontsourceMeta(family) : null; for (const spec of new Set(specs)) { const weight = parseInt(spec, 10); const style = spec.endsWith('i') ? 'italic' : 'normal'; if (hasFace(family, weight, style)) continue; if (optional && !(meta?.weights.includes(weight) && meta.styles.includes(style))) continue; for (const subset of subsets) { const url = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@5/files/${id}-${subset}-${weight}-${style}.woff2`; const face = new FontFace(family, `url(${url}) format('woff2')`, { weight: String(weight), style, unicodeRange: ranges[subset] }); jobs.push(face.load().then((ready) => { document.fonts.add(ready); added++; }, () => { if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`); })); } } } await Promise.all(jobs).catch((error) => { kitFail(error); throw error; }); return added; } /** Runs `build` (a buildDocument or buildBundle call) and checks the faces * the pages use. A regular face missing from FONTS is loaded with a warning; * bold and italic variants are loaded when the family ships them. Then the * measurement caches are cleared and the build runs again. */ async function buildWithFonts(build, text = '') { const tried = new Set(); for (let round = 0; round < 3; round++) { kitStatus('Laying out…'); await new Promise(requestAnimationFrame); // let the status paint first const result = await Promise.resolve().then(build).catch((error) => { kitFail(error); throw error; }); const wanted = { base: {}, variants: {} }; for (const { font, base } of [result].flat().flatMap(fontStringsOf)) { const { family, weight, style } = parseFont(font); const key = `${family}|${weight}|${style}`; if (tried.has(key) || hasFace(family, weight, style)) continue; tried.add(key); (wanted[base ? 'base' : 'variants'][family] ??= []).push(`${weight}${style === 'italic' ? 'i' : ''}`); } if (Object.keys(wanted.base).length) { console.warn(`[cookbook] FONTS does not list ${JSON.stringify(wanted.base)}: loading them.`); } const added = await loadFonts(wanted.base, text) + await loadFonts(wanted.variants, text, { optional: true }); if (added === 0) return result; clearMeasurementCache(); } throw new Error('The fonts did not settle after three builds.'); } /** Every font string of the layout. `base` marks a block's own face; its * bold, italic and bold-italic variants are listed whether or not used. */ function fontStringsOf(doc) { const found = new Map(); const walk = (node) => { if (!node || typeof node !== 'object') return; if (Array.isArray(node)) { node.forEach(walk); return; } for (const [key, value] of Object.entries(node)) { if (typeof value === 'string' && /fontString$/i.test(key)) { found.set(value, found.get(value) || key === 'fontString'); } else if (value && typeof value === 'object') walk(value); } }; walk(doc.pages); walk(doc.blocks); return [...found].map(([font, base]) => ({ font, base })); } /** '700 37.5px Open Sans' / 'italic 400 13px "Source Serif 4"' → { family, weight, style }. * A string with no weight ('95.8px Young Serif', from a design text) is 400. */ function parseFont(font) { const m = /^(?:(italic|oblique)\s+)?(?:small-caps\s+)?(?:(\d+|bold|normal)\s+)?[\d.]+px\s+(.+)$/.exec(font.trim()); if (!m) throw new Error(`Unexpected font string: ${font}`); const weight = m[2] === 'bold' ? 700 : !m[2] || m[2] === 'normal' ? 400 : Number(m[2]); return { family: m[3].replace(/^["']|["']$/g, ''), weight, style: m[1] ? 'italic' : 'normal' }; } /** True when a loaded FontFace covers exactly this family, weight and style * (document.fonts.check() is also true for families nobody declared). */ function hasFace(family, weight, style) { for (const face of document.fonts) { if (face.status !== 'loaded' || face.style !== style) continue; if (face.family.replace(/^["']|["']$/g, '') !== family) continue; const [low, high = low] = face.weight.split(' ').map(Number); if (weight >= low && weight <= high) return true; } return false; } /** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */ function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); } /** The weights and styles a family ships ({ weights: [400, 700], styles: ['normal', 'italic'] }), or null. */ function fontsourceMeta(family) { fontsourceMeta.cache ??= new Map(); const id = fontsourceId(family); if (!fontsourceMeta.cache.has(id)) { fontsourceMeta.cache.set(id, fetch(`https://api.fontsource.org/v1/fonts/${id}`) .then((res) => (res.ok ? res.json() : null), () => null)); } return fontsourceMeta.cache.get(id); } // ─── Kit · viewer v1 ── the same in every recipe · postext.dev/cookbook ─────── /** Shows the pages as facing spreads on a dark desk: the first page is a * recto on its own, then verso | recto pairs, as in a bound book. Pages * are painted when they scroll near the screen. */ function showPages(docs, { title, width = 460 } = {}) { const root = viewer(title); const pages = [docs].flat().flatMap((doc) => doc.pages.map((page) => ({ doc, page, n: (doc.pageIndexOffset ?? 0) + page.index }))); const spreads = []; let verso = null; for (const p of pages) { if (p.n % 2 === 1) { if (verso) spreads.push([verso, null]); verso = p; } else { spreads.push([verso, p]); verso = null; } } if (verso) spreads.push([verso, null]); const density = Math.min(window.devicePixelRatio || 1, 2); showPages.painter?.disconnect(); const painter = new IntersectionObserver((entries) => { for (const { isIntersecting, target } of entries) { if (!isIntersecting) continue; painter.unobserve(target); const { doc, page } = target.postext; renderPageToCanvas(page, doc, target, { scale: (width * density) / page.width }); } }, { rootMargin: '800px' }); showPages.painter = painter; root.replaceChildren(...spreads.map((pair) => { const spread = document.createElement('div'); spread.className = 'pt-spread'; for (const p of pair) { const figure = document.createElement('figure'); if (p) { const label = p.page.pageLabel || String(p.n + 1); const canvas = document.createElement('canvas'); canvas.postext = p; canvas.style.aspectRatio = `${p.page.width} / ${p.page.height}`; canvas.setAttribute('role', 'img'); canvas.setAttribute('aria-label', `Page ${label}`); const folio = document.createElement('figcaption'); folio.textContent = label; figure.append(canvas, folio); painter.observe(canvas); } else figure.className = 'pt-blank'; spread.append(figure); } return spread; })); kitStatus(`${pages.length} ${pages.length === 1 ? 'page' : 'pages'}`); document.documentElement.dataset.postext = 'ready'; return pages.length; } /** The desk, the bar and the error reporting, created once. */ function viewer(title) { if (!document.getElementById('pt-kit')) { document.head.insertAdjacentHTML('beforeend', `<style id="pt-kit"> :root { color-scheme: dark; } body { margin: 0; background: #0e1014; color: #b9bcc4; font: 13px/1.45 system-ui, sans-serif; } #pt-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 10px 16px; background: rgb(14 16 20 / .92); backdrop-filter: blur(6px); border-bottom: 1px solid #23262d; } #pt-bar strong { color: #f4f1ea; font-weight: 600; } #pt-actions { display: flex; gap: 12px; margin-left: auto; } #pt-actions a, #pt-actions button { color: #d8a21a; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; } #pages { display: grid; justify-items: center; gap: 48px; padding: 32px 16px 72px; } .pt-spread { display: flex; } .pt-spread figure { margin: 0; width: min(460px, 44vw); } .pt-spread canvas { display: block; width: 100%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); } .pt-spread figure:first-child canvas { box-shadow: inset -14px 0 14px -14px rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); } .pt-spread figcaption { margin-top: 10px; text-align: center; font: 600 10px/1 system-ui, sans-serif; letter-spacing: .18em; text-transform: uppercase; color: #6c7079; } .pt-blank { visibility: hidden; } @media (max-width: 760px) { .pt-spread { flex-direction: column; gap: 32px; } .pt-spread figure { width: min(460px, 92vw); } .pt-blank { display: none; } } </style>`); document.body.insertAdjacentHTML('afterbegin', '<header id="pt-bar"><strong id="pt-title"></strong><span id="pt-status" role="status"></span><span id="pt-actions"></span></header>'); document.getElementById('pt-title').textContent = document.title || 'Postext'; addEventListener('error', (event) => kitFail(event.error ?? event.message)); addEventListener('unhandledrejection', (event) => kitFail(event.reason)); } if (title) document.getElementById('pt-title').textContent = title; return document.getElementById('pages') ?? document.body.appendChild(Object.assign(document.createElement('main'), { id: 'pages' })); } function kitStatus(text) { viewer(); document.getElementById('pt-status').textContent = text; } function kitFail(error) { document.documentElement.dataset.postext = 'error'; kitStatus(`Error: ${error?.message ?? error}`); } // ─── Kit · pdf v1 ── the same in every recipe that exports a PDF ────────────── /** postext-pdf embeds TrueType bytes. Fetch the Fontsource file the screen * used, snapping to a weight the family ships and falling back to upright * when it has no italic: the PDF asks for every face a block could use. */ async function fontsourceProvider(family, weight, style) { const id = fontsourceId(family); const meta = await fontsourceMeta(family); const weights = meta?.weights?.length ? meta.weights : [400, 700]; const w = weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)); const s = style === 'italic' && meta && !meta.styles.includes('italic') ? 'normal' : style; const res = await fetch(`https://cdn.jsdelivr.net/npm/@fontsource/${id}@5/files/${id}-latin-${w}-${s}.woff2`); if (!res.ok) throw new Error(`Fontsource has no ${family} ${w} ${s} (${res.status})`); return decompressWoff2(new Uint8Array(await res.arrayBuffer())); } /** A "Build the PDF" button in the bar. Once built: "Open the PDF" (a new * tab, since CodePen's preview frame cannot show PDFs) and a download link. */ function offerPdf(makePdf, filename) { viewer(); const button = Object.assign(document.createElement('button'), { type: 'button', textContent: 'Build the PDF' }); button.dataset.postextPdf = filename; button.addEventListener('click', async () => { button.disabled = true; button.textContent = 'Building the PDF…'; try { const bytes = await makePdf(); const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' })); const size = `${Math.max(1, Math.round(bytes.length / 1024))} KB`; button.replaceWith( Object.assign(document.createElement('a'), { href: url, target: '_blank', rel: 'noopener', textContent: 'Open the PDF ↗' }), Object.assign(document.createElement('a'), { href: url, download: filename, textContent: `Download ${filename} · ${size}` })); } catch (error) { button.disabled = false; button.textContent = 'Build the PDF'; kitFail(error); } }); document.getElementById('pt-actions').append(button); } // ─── Kit · images v1 ── recipes with pictures · postext.dev/cookbook ────────── /** Registers a photo or PNG for the canvas and keeps its bytes for the PDF. * fetch → ImageBitmap never taints the canvas (a plain cross-origin <img> would). */ async function loadImage(fileId, url) { const res = await fetch(url); if (!res.ok) throw new Error(`Image not found (${res.status}): ${url}`); const bytes = new Uint8Array(await res.arrayBuffer()); registerResourceImage(fileId, await createImageBitmap(new Blob([bytes]))); (loadImage.bytes ??= new Map()).set(fileId, bytes); } /** Registers SVG markup (drawn in code, or fetched) as a vector image. */ async function loadSvg(fileId, svg) { const img = new Image(); img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`; await img.decode(); registerResourceImage(fileId, img); (loadImage.bytes ??= new Map()).set(fileId, new TextEncoder().encode(svg)); } /** renderToPdf({ resourceBytes: imageBytes }) */ function imageBytes(fileId) { return loadImage.bytes?.get(fileId); } /** renderToHtml({ resourceImageUrl: imageUrl }) */ function imageUrl(fileId) { const bytes = imageBytes(fileId); if (!bytes) return undefined; imageUrl.urls ??= new Map(); if (!imageUrl.urls.has(fileId)) { const type = /\.svg$/i.test(fileId) ? 'image/svg+xml' : /\.png$/i.test(fileId) ? 'image/png' : 'image/jpeg'; imageUrl.urls.set(fileId, URL.createObjectURL(new Blob([bytes], { type }))); } return imageUrl.urls.get(fileId); } // ─── /Kit ───────────────────────────────────────────────────────────────────────

组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)

变化

#改用温哥华格式的编号引用

医学期刊常给引用编号;BibTeX和正文都不用改。

-  citations: { style: 'apa', link: true,
+  citations: { style: 'elsevier-vancouver', marker: 'superscript', link: true,

#加上ClinicalTrials.gov编号

这项试验被认为无需注册,文中也这样写明。已注册的试验在摘要框的同一行写出注册机构和编号,例如**Trial registration** ClinicalTrials.gov NCT01234567,换成你自己的注册号。

#没有分析行的流程图

如果报告没有说明分析了哪些人,就让每个分支止于随访框:删去an节点及其箭头,并调小CONSORT_H。

常见问题

易错点

SVG <img>中的文字不能使用网络字体

SVG作为图像绘制,而图像无法使用页面的网络字体,所以其中的标签会退回系统字体。把文字转成轮廓,在SVG中嵌入@font-face子集,或者把标签移到题注里。 作为资源的图和表 →

易错点

SVG插图中不要用<marker>或滤镜(会退回位图)

SVG图只有在不含<marker>、滤镜和蒙版时,才能在PDF中保持矢量;否则会退回位图,而且层层嵌套的滤镜可能让它在Chrome中变成空白。箭头用路径来画。 作为资源的图和表 →

易错点

Fontsource的latin文件不含拉丁字母以外的字形

PDF字体提供函数嵌入的是Fontsource的latin文件,它们覆盖西班牙语和西欧文字,但不包括→、≈、✓、★、希腊字母或中欧字母;这些字形在PDF中会缺失。PDF中的文字要保持在latin范围内。 嵌入PDF的字体 →

易错点

合并单元格需要hiddenBy占位:使用mergeCells

单元格按其在行数组中的位置排布,所以合并单元格延伸到的地方需要标记hiddenBy的占位单元格;像HTML那样省略它们,后面的每一列都会错位。用mergeCells来合并。 由数据生成的表 →

易错点

单独的$会开始数学公式:写成\$

美元符号会开始行内公式,所以$40这样的价格会变成公式的开头。写成\$40。 转义与字面字符 →

易错点

传入任何headings对象都会关掉H1换页

默认情况下,H1换页到右页(always-odd),但只要传入headings对象,这个默认值就会被重置,于是各章接排,span: 'page'也不起作用。在每份配置中重新写明headings.levels[0].breakBefore: { enabled: true, parity }。 从右页开始的章 →

易错点

'top'浮动体不会出现在引用它的那一页

浮动体不会排在自己的引用之前,所以在第N页引用的整页宽'top'浮动体会出现在第N+1页的顶部。把引用提前,或者使用position 'auto'或'bottom',它们可以占用引用页的底部。 图的放置 →

易错点

排版前加载所有字体

排版用浏览器已加载的字体测量文字,并缓存宽度,所以首次构建之后才到的字体会造成断行错误,PDF也不再与屏幕一致。先加载所有字重和样式;有字体迟到时,重新构建前调用clearMeasurementCache()。 排版前加载字体 →

易错点

配置按对象身份缓存:每次新建一个对象

引擎按对象身份缓存解析后的配置,所以就地修改配置再构建,会复用旧的结果。每次构建都新建一个对象,这也是食谱的配置写成工厂函数config()的原因。 在Canvas上绘制页面 →

  • 这篇论文没有NCT编号:作者写明该试验无需注册。注册行照此说明,并引用论文给出的理由,而不是编造一个编号。
  • 与横跨全页的图共用一栏的表格,会在栏底前三行处停止,在下一页继续。表1之所以能完整放下,是因为表行用7.5 pt、0.45 mm内边距,CONSORT图高107 mm。
  • 论文的卡方检验写作χ²。这里PDF的字体来自Fontsource的latin文件,不含希腊字母,所以本版把它写成单词,并在版权页中注明。

致谢

文本
  • Text and data: Fitzpatrick KK, Darcy A, Vierhile M. Delivering Cognitive Behavior Therapy to Young Adults With Symptoms of Depression and Anxiety Using a Fully Automated Conversational Agent (Woebot): A Randomized Controlled Trial. JMIR Mental Health 2017;4(2):e19, doi:10.2196/mental.7785. Originally published in JMIR Mental Health (http://mental.jmir.org), 06.06.2017. Abridged; figures redrawn in code from the article's numbers; citations converted to APA author–date · © Kathleen Kara Fitzpatrick, Alison Darcy, Molly Vierhile · CC BY 4.0
字体
Lora (SIL OFL 1.1) · Nunito Sans (SIL OFL 1.1)
沙盒PDF