Kurz gesagt
Ein bekannter Open-Access-Essay dazu, warum viele Forschungsergebnisse nicht standhalten, als siebenseitiger Nachdruck. Ein Skript erzeugt eine englische und eine spanische Ausgabe, jede mit eigener Trennung, Dezimalkomma und Bezeichnungen.
Was Sie setzen
Einen siebenseitigen Nachdruck von John Ioannidis’ Essay Why Most Published Research Findings Are False (PLoS Medicine, 2005), gekürzt und auf einer Seite von 210 × 280 mm in zwei Spalten gesetzt. Ein marineblaues Band eröffnet die erste Seite, und hinter dem Titel stehen blass die Kurven der Formel, um die es im Essay geht. Die drei Formeln sind nummerierte, abgesetzte Gleichungen; die Vierfeldertafeln haben in jeder Zelle eine Formel mit echtem α und β; Abbildung 1 ist aus Gl. (2) berechnet, ebenso die letzte Spalte von Tabelle 4. Dasselbe Skript baut eine spanische Übersetzung mit spanischer Silbentrennung, Dezimalkomma in Tabellen und Abbildungen, Anführungszeichen « » und spanischen Bezeichnungen. Es folgen 33 Literaturangaben im Vancouver-Stil, aus der Liste des Artikels als BibTeX nachgebaut.
Dieses Rezept beantwortet
- Wie veröffentliche ich einen Artikel aus einem Skript in zwei Sprachen, jeweils mit der Typografie der Sprache?
- Wie erstelle ich eine Tabelle mit Kopfzeilen, verbundenen Zellen, Spaltenbreiten und Ausrichtung je Zelle?
- Wie setze ich Formeln (im Text, abgesetzt, Gleichungen) und behalte sie im PDF als Vektoren?
- Wie setze ich einen Open-Access-Artikel aus arXiv oder PubMed Central mit Postext neu, mit seinen Zitaten, Abbildungen und seiner Lizenzzeile?
Die kurze Antwort
// 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)
Zutaten
- Funktionen
- MathematikTabellen aus DatenSilbentrennung und DokumentspracheTabellenformatAbbildung und Tabelle in Ihrer SpracheZitate in einem ZitierstilLiteraturverzeichnis aus den QuellenAbbildungen und Tabellen als RessourcenVerweise, die Abbildungen platzierenNummerierte BildunterschriftenPlatzierung von AbbildungenFormat der BildunterschriftGestaltete AuftakteÜberschriftenattributeKästen über die SeiteKästenGleitende KästenKurze Spalten füllenInline-ChipsPDF-Export
- Nutzt außerdem
- Spalten in einem Kasten oder im TextSpaltenausgleichÜberschriftenformateKopfzeilen nach SeitenrolleAbsatzformateIm PDF eingebettete SchriftenEigene RessourcentypenHoch- und TiefstellungKapitel ohne Nummer
- Schrift
- Gelasio, Sofia Sans Semi Condensed (SIL OFL 1.1)
- Dateien
- Keine: Jedes Bild wird im Code gezeichnet
Zubereitung
#1 · Ein Skript, zwei Ausgaben
Der Code steht oben in der kurzen Antwort. Die Rezepte stellen den Pen für jede Sprache einmal zusammen und setzen content.en.md oder content.es.md dort ein, wo der Platzhalter @content steht; jeder benannte Slot (content.corollaries.es.md, content.resources.es.md) folgt derselben Regel, und ein Slot ohne spanische Datei fällt auf Englisch zurück. So teilen sich beide Ausgaben eine BibTeX-Datei. Alles andere, was sich mit der Sprache ändert, läuft über LANG: locale wählt die Trennmuster ('es' ist der Code, der Spanisch trennt), defaultResourceTypes(LANG) schreibt Tabla und Figura, die CSL-Locale schreibt die Wörter des Literaturverzeichnisses, und toLocaleString gibt den Zahlen, die das Skript berechnet, ihr Dezimalkomma. Die Übersetzung folgt spanischer Typografie: Anführungszeichen « », 0,05 im Text und 0{,}05 in einer Formel, damit TeX das Komma nicht als Satzzeichen mit nachfolgendem Leerraum setzt. Wenn Sie Ihren eigenen Artikel in zwei Sprachen veröffentlichen wollen, halten Sie für Text und Legenden je eine Datei pro Sprache und legen Sie jeden anderen Unterschied in ein einziges Objekt wie edition.
#2 · Formeln in Tabellenzellen
// 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');
Eine Tabellenzelle setzt $…$ wie der Text (seit postext 1.19), eine Zelle mit $c(1-\beta)R/(R+1)$ in der TSV ist also eine Formel: MathJax-Pfade in den 8 pt der Zellen, auf der Grundlinie der Zellzeile, sodass Yes, No und die Formeln auf einer Linie stehen, und Vektorkonturen im PDF. Die Latin-Dateien von Fontsource enthalten keine griechischen Buchstaben, und die Formeln brauchen keine. Auch Legenden und Anmerkungen nehmen Mathematik auf: Die Legende von Tabelle 4 nennt die Teststärke 1 − β, und ihre Anmerkung setzt α = 0,05 voraus, so wie der Artikel von 2005 sie druckt. setAlignment setzt die Zahlen von Tabelle 4 rechtsbündig, und mergeCells verbindet Research finding über beide Kopfzeilen und True relationship über drei Spalten; es schreibt auch die verborgenen Platzhalterzellen, die eine verbundene Zelle braucht.
#3 · Legenden und Tabellen aus dem Platz, Zahlen aus der Formel
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') } };
Die Tabellen, Legenden, Anmerkungen und Alternativtexte stehen in content.resources.<lang>.md, je ein Block, sodass eine Übersetzerin nur Textdateien bearbeitet und jede Ausgabe nur ihre eigene Sprache mitführt. Die PPV-Spalte von Tabelle 4 ist nicht eingetippt: ppv() berechnet sie aus Teststärke, R und u jeder Zeile, und die neun Werte stimmen auf zwei signifikante Stellen mit den 2005 gedruckten überein. Die Tabellen gleiten mit position: 'auto', sodass Tabelle 1 den Fuß der Seite einnehmen kann, die sie zitiert, statt sich mit den anderen Gleitobjekten auf der nächsten zu stauen.
#4 · Abbildung 1, aus Gl. (2) gezeichnet
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>`;
Jedes Feld ist eine Schleife über R von 0 bis 1 durch dieselbe Funktion ppv(), die Tabelle 4 füllt. Wer die Kurven aus der Formel zeichnet, sieht etwas, das die Abbildung von 2005 verbirgt: Ihre Kurven entsprechen u = 0, 0,05, 0,20 und 0,80, ihre Legende nennt aber 0,05, 0,20, 0,50 und 0,80. Diese Fassung zeichnet die Werte der Zeichenerklärung, ergänzt den Fall ohne Verzerrung als gestrichelte Kurve, und die Anmerkung zur Legende sagt das. Die Beschriftungen in der Grafik sind Text, der die Beschriftungsschrift angibt: loadSvg reicht die Zeichnung durch inlineSvgFonts, das diese Schrift für das Canvas einbettet, und das PDF setzt sie in der Schrift, die der Provider liefert.
#5 · Eine erste Seite und ein Kasten für einen Essay
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 }),
] } };
Der Titel ist die einzige Überschrift der Ebene 1; ihr Stil essay reicht über die ganze Seitenbreite und zeichnet Band, Dachzeile, Autor, Institutionen und Quellenzeile aus Attributen der Überschrift, sodass die spanische Ausgabe nur Wörter ändert. Die Zusammenfassung ist ein seitenbreiter Kasten auf einer Tönung. Kasten 1, das durchgerechnete Beispiel, gleitet über beide Spalten an den Fuß einer Seite und setzt seinen Text im Kasten in zwei Spalten. Die Folgerungen behalten die Form des Artikels mit eingezogenem Anfang: :chip[Corollary 1]{style="corollary"} gibt jeder einen kleinen zinnoberroten Chip vor ihrer fetten Aussage.
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) }];
Die Notiz der Zeitschrift auf der ersten Seite, Interessenkonflikte und Abkürzung, ist ein Kasten im Stil note mit placement: 'bottom': Er rückt an den Fuß der ersten Spalte, die Platz für ihn hat, unter eine feine Linie, und auf Seite 1 der englischen Ausgabe enden beide Spalten auf gleicher Höhe. headings.balancing.fillShortColumns lässt einen Absatz eine Zeile länger laufen, sodass die beiden Spalten der Literaturangaben auf der letzten Seite gleich hoch enden.
Das ganze Rezept
// ═══ 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
Das zusammengesetzte script.js läuft unverändert: Fügen Sie es in das Modulskript einer beliebigen Seite ein, oder öffnen Sie das Rezept auf CodePen. Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)
Varianten
#Zitatnummern hochstellen
Medizinische Zeitschriften setzen Vancouver-Nummern oft hochgestellt.
- marker: 'brackets', collapseRanges: true,
+ marker: 'superscript', collapseRanges: true,#DOIs drucken
Das BibTeX dieses Rezepts enthält keine DOIs, damit der Pen in seiner Größe bleibt. Behalten Sie sie in Ihrer eigenen Datei und geben Sie sie als Links aus.
- labelWidth: mm(6.4), doi: 'hide' } },
+ labelWidth: mm(6.4), doi: 'link' } },#Die Tabellen einspaltig setzen
Eine Vierfeldertafel mit kürzeren Formeln passt in eine Spalte: Entfernen Sie ihr span: 'page', so wie Tabelle 4 keines hat. Eine einspaltige Tabelle zeigt Zweispaltiger Aufsatz mit nummerierten Gleichungen.
Häufige Fehler
Häufiger Fehler
Mathematik braucht await initMathEngine() vor dem ersten Build
Formeln, die gesetzt werden, bevor die Mathematik-Engine läuft, sind graue Platzhalterkästen. Importieren Sie initMathEngine mit den anderen Symbolen aus https://esm.sh/postext und warten Sie es vor dem ersten Build ab; ein Dokument mit Mathematik, das ohne es gebaut wird, gibt eine Konsolenwarnung aus. Seit postext 1.5 wird MathJax im Paket als ein Modul mitgeliefert, das initMathEngine nachlädt, sodass der einfache Import von einem CDN funktioniert und ?bundle nicht gebraucht wird (bis 1.4 musste jedes Symbol von https://esm.sh/postext?bundle kommen). Importieren Sie nur von einer URL: zwei URLs laden zwei Engines. Mathematik →
Häufiger Fehler
Fontsource-Dateien decken Buchstaben ab, keine Symbole
Das Kit bettet die latin-Datei einer Schrift von Fontsource ein, dazu ihre latin-ext-Datei für č, ł, † und ihre greek-Datei für α, χ (bei einer Familie, die eine mitliefert: Lora und Gelasio tun es nicht), wenn der Text diese Zeichen setzt, auf dem Bildschirm und im PDF. Symbole wie →, ≈, ✓ und ★ stehen in keiner dieser Dateien und fehlen im PDF: zeichnen Sie sie, setzen Sie sie als Mathematik oder wählen Sie eine Schrift, deren Dateien sie enthalten. Im PDF eingebettete Schriften →
Häufiger Fehler
Ein einzelnes $ eröffnet Mathematik: \$ schreiben
Ein Dollarzeichen eröffnet Mathematik im Text, sodass ein Preis wie $40 eine Formel beginnt. Schreiben Sie \$40. Maskierung und wörtliche Zeichen →
- Wo die Liste von 2005 nach fünf Autoren mit et al. endet, schließt das BibTeX die Liste mit
and others, undelsevier-vancouversetzt an dieser Stelle et al. (seit postext 1.19; frühere Versionen gaben einen Mitautor namens others aus). - Die Seiten der beiden Ausgaben unterscheiden sich: Der spanische Text ist länger, deshalb steht Tabelle 4 eine Seite später. Die Aufnahme veröffentlicht von beiden die Seiten 1, 2, 3, 5, 6 und 7, damit die Seitenbilder unter der Größengrenze bleiben und Tabelle 4 trotzdem in jeder zu sehen ist.
Nachweise
- Rezept
- Ignacio Ferro
- Text
- “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
- Schriften
- Gelasio (SIL OFL 1.1) · Sofia Sans Semi Condensed (SIL OFL 1.1)
- Code
- MIT, wie Postext
Diesen Text bearbeiten ↗ (öffnet sich in einem neuen Tab)Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)


