باختصار
مقال شهير مفتوح الوصول عن سبب عدم صمود كثير من نتائج الأبحاث، منضَّد في مستلة من سبع صفحات. نص برمجي واحد يصنع الطبعة الإنجليزية وترجمة إسبانية، ولكل منهما تقطيع كلماتها وفاصلتها العشرية وتسمياتها.
ما الذي ستنضده
مستلة من سبع صفحات لمقال John Ioannidis Why Most Published Research Findings Are False (PLoS Medicine، 2005)، مختصرة ومنضدة على صفحة قياسها 210 × 280 مم في عمودين. يفتتح الصفحة الأولى شريط كحلي رُسمت عليه بخفة، خلف العنوان، منحنيات الصيغة التي يقوم عليها المقال. الصيغ الثلاث صيغ معروضة مرقّمة؛ وفي كل خلية من جداول 2×2 صيغة بحرفي α وβ الحقيقيين؛ والشكل 1 محسوب من المعادلة (2)، وكذلك العمود الأخير من الجدول 4. والنص البرمجي نفسه ينضّد ترجمة إسبانية بتقطيع الكلمات الإسباني، والفاصلة العشرية في الجداول والأشكال، وعلامتي التنصيص « »، وتسميات بالإسبانية. وتختم المقال ثلاثة وثلاثون مرجعًا بأسلوب فانكوفر، أعيد بناؤها بصيغة BibTeX من قائمة مراجع الورقة.
تجيب هذه الوصفة عن
- كيف أنشر ورقة واحدة بلغتين من نص برمجي واحد، مع طباعة كل لغة؟
- كيف أصنع جدولًا فيه صفوف رأس، وخلايا مدمجة، وعروض أعمدة، ومحاذاة لكل خلية؟
- كيف أنضد الرياضيات (مضمّنة، ومعروضة، ومعادلات) وأبقيها متجهية في ملف PDF؟
- كيف أعيد تنضيد ورقة بحثية مفتوحة الوصول من arXiv أو PubMed Central بـPostext، مع استشهاداتها وأشكالها وسطر ترخيصها؟
الجواب المختصر
// 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)
المكونات
- الميزات
- الرياضياتجداول من البياناتتقسيم الكلمات ولغة المستندنمط الجدول«شكل» و«جدول» بلغتكالاستشهادات بأسلوب توثيققائمة المراجع من البيانات المرجعيةالأشكال والجداول بوصفها موارداستشهادات تضع الأشكالتعليقات مرقّمةموضع الأشكالنمط التعليقصفحات افتتاح مصمَّمةسمات العنوانإطارات بعرض الصفحةإطارات التنبيهإطارات عائمةملء الأعمدة القصيرةالشارات داخل السطرالتصدير إلى PDF
- تستخدم أيضًا
- أعمدة داخل الإطار أو النصموازنة الأعمدةأنماط العناوينالترويسات بحسب دور الصفحةأنماط الفقراتالخطوط المضمَّنة في PDFأنواع موارد مخصّصةالنص المرتفع والمنخفضفصول بلا أرقام
- الخطوط
- Gelasio, Sofia Sans Semi Condensed (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · نص برمجي واحد، وطبعتان
الشيفرة هي الجواب المختصر أعلاه. يركّب كتاب الوصفات النص البرمجي مرة لكل لغة، ويضع content.en.md أو content.es.md حيث تقف علامة @content؛ وتتبع كل خانة مسماة (content.corollaries.es.md وcontent.resources.es.md) القاعدة نفسها، والخانة التي لا ملف إسبانيًا لها تأخذ الملف الإنجليزي، وبذلك تتقاسم الطبعتان ملف BibTeX واحدًا. وكل ما سوى ذلك مما يتغير مع اللغة يمر عبر LANG: يختار locale أنماط تقطيع الكلمات ('es' هو الرمز الذي يقطّع الإسبانية)، ويكتب defaultResourceTypes(LANG) كلمتي Tabla وFigura، وتكتب إعدادات CSL الإقليمية كلمات قائمة المراجع، ويضع toLocaleString الفاصلة العشرية الصحيحة في الأرقام التي يحسبها النص البرمجي. وتتبع الترجمة أعراف الطباعة الإسبانية: علامتا التنصيص « »، و0,05 في المتن و0{,}05 داخل الصيغة، كي لا يعامل TeX الفاصلة علامةَ ترقيم ويضع بعدها مسافة. ولتنشر ورقتك بلغتين، احفظ ملفًا لكل لغة للنص والتعليقات، واجمع كل فرق آخر في كائن واحد مثل edition.
#2 · صيغ داخل خلايا الجدول
// A cell, a caption or a note sets $…$ as the text does (postext ≥ 1.19): MathJax paths at
// the cell's 8 pt, on the baseline of its line and aligned with the cell, vector in the PDF.
// The faces' latin files have no α or β (gotcha: latin-subset); the formulas need none.
const [CELL_PT, PAD] = [8, 1]; // cell type (pt), cell padding (mm)
function tableModel(tsv, widths, headerRows, merges = [], right = []) {
let model = { ...parseTSV(tsv, { headerRows }), columnWidths: widths };
model.rows.forEach((_, row) => right.forEach((c) => {
model = setAlignment(model, { row, col: c }, 'right'); // the numbers, the PPV and their heads
}));
for (const range of merges) model = mergeCells(model, range); // gotcha: merged-cells-hiddenby
return model;
}
// "Research finding" over both header rows, "True relationship" over Yes, No and Total.
const twoByTwo = (tsv) => tableModel(tsv, [1.1, 1.6, 1.6, 2.5], 2, [
{ start: { row: 0, col: 0 }, end: { row: 1, col: 0 } },
{ start: { row: 0, col: 1 }, end: { row: 0, col: 3 } }]);
// Table 4's last column is computed from Eq. (2), α = 0.05: two significant figures, as in 2005.
const ppv = (power, R, u, alpha = 0.05) => (power * R + u * (1 - power) * R)
/ (R + alpha - (1 - power) * R + u - u * alpha + u * (1 - power) * R);
const read = (s) => Number(s.replace(',', '.'));
const odds = (s) => s.split(':').map((x) => Number(x.replace(/\D/g, ''))).reduce((a, b) => a / b);
const ppvRows = (tsv) => tsv.split('\n').map((line, r) => {
const [power, R, u, example, head] = line.split('\t');
const p = ppv(read(power), odds(R), read(u)); // 0.0010: as many decimals as 2 figures need
return [power, R, u, example, r ? number(p, 1 - Math.floor(Math.log10(p))) : head].join('\t');
}).join('\n');
منذ postext 1.19 تنضّد خلية الجدول $…$ كما ينضّدها النص، فالخلية المكتوبة في TSV بالشكل $c(1-\beta)R/(R+1)$ صيغةٌ: مسارات MathJax بحجم 8 pt الخاص بالخلايا، على خط أساس سطر الخلية، فتقف Yes وNo والصيغ على سطر واحد، وتبقى خطوطًا متجهية في ملف PDF. لا تحوي ملفات latin في Fontsource حروفًا يونانية، ولا تحتاج إليها الصيغ. وتقبل التعليقات والملاحظات الرياضيات أيضًا: يذكر تعليق الجدول 4 القوة الإحصائية 1 − β، وتفترض ملاحظته α = 0.05، كما طُبعا في ورقة 2005. ويحاذي setAlignment أرقام الجدول 4 إلى اليمين، ويمد mergeCells عنوان Research finding على صفي الرأس، وTrue relationship على ثلاثة أعمدة، ويكتب الخلايا المخفية التي تحتاجها الخلية المدمجة.
#3 · الجداول والتعليقات من الخانة، والأرقام من الصيغة
const parsed = blocks.trim().split(/\n\s*\n/).map((block) => {
const fields = {};
const tsv = block.split('\n').filter((line) => {
const m = /^(id|caption|note|alt): (.*)$/.exec(line);
if (m) fields[m[1]] = m[2];
return !m;
}).join('\n');
return { ...fields, tsv };
});
const tables = parsed.filter((b) => b.tsv).map(({ id, caption, note, tsv }) => {
const model = id === 'tbl-ppv'
? tableModel(ppvRows(tsv), [0.8, 0.95, 0.75, 3.8, 1.05], 1, [], [0, 1, 2, 4])
: twoByTwo(tsv);
return { id, typeId: 'table', kind: 'table', createdAt: 0, updatedAt: 0, caption, note,
table: { model }, placement: { position: 'auto', ...(id !== 'tbl-ppv' && { span: 'page' }) } };
});
const figures = parsed.filter((b) => !b.tsv).map(({ id, caption, note, alt }) => ({ id,
typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0, caption, note, altText: alt,
placement: { position: 'auto', span: 'page' },
svg: { fileId: `${id}.svg`, width: FIG_W * 10, height: FIG_H * 10 } }));
const resources = [...tables, ...figures,
{ id: 'band-art', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
svg: { fileId: 'band-art.svg', width: 1400, height: BAND * 10 } }];
const tableStyle = { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
headerBackground: col('navy'), headerColor: col('paper'), headerBold: true,
headerFontFamily: SANS, headerFontSize: pt(CELL_PT), bodyFontFamily: SANS,
bodyFontSize: pt(CELL_PT), bodyColor: col('ink'), cellPadding: mm(PAD) };
const captionStyle = { fontFamily: SANS, fontSize: pt(8.2), color: col('ink'), labelBold: true,
labelColor: col('accent'), gap: mm(2), note: { fontSize: pt(7), color: col('muted') } };
الجداول والتعليقات والحواشي والنصوص البديلة موجودة في content.resources.<lang>.md، كتلة لكل مورد، فلا يعدّل المترجم إلا ملفات نصية، ولا تتضمّن كل طبعة إلا لغتها. ولا يُكتب عمود PPV في الجدول 4 باليد: تحسبه ppv() من القوة الإحصائية وR وu في كل صف، وتطابق القيم التسع ما طُبع عام 2005 في رقمين معنويين. وتطفو الجداول بالقيمة position: 'auto'، فيستطيع الجدول 1 أن يأخذ أسفل الصفحة التي تستشهد به بدل أن يتكدس مع العناصر العائمة الأخرى في الصفحة التالية.
#4 · الشكل 1 مرسومًا من المعادلة (2)
const R2 = (x) => Math.round(x * 100) / 100;
// Each label names the label face: loadSvg embeds it for the canvas (inlineSvgFonts), and the
// PDF asks the provider for it.
const mix = (f) => `#${[1, 3, 5].map((i) => Math.round(parseInt(palette.navy.slice(i, i + 2), 16)
* (1 - f) + parseInt(palette.accent.slice(i, i + 2), 16) * f).toString(16).padStart(2, '0'))
.join('')}`; // navy for the first curve, vermilion for the last
const label = (x, y, s, size, extra = '', fill = palette.muted) => `<text x="${R2(x)}" `
+ `y="${R2(y)}" font-size="${size}" font-family="${SANS}" fill="${fill}" ${extra}>${s}</text>`;
const line = (points, stroke, width, extra = '') => `<path d="M${points.map(([x, y]) =>
`${R2(x)} ${R2(y)}`).join('L')}" fill="none" stroke="${stroke}" stroke-width="${width}" `
+ `${extra}/>`;
// Three panels, power 0.80, 0.50 and 0.20; PPV in % against R from 0 to 1, one curve per value.
function panels(curve, values, name, digits, dashed) {
const [pw, top, plotH, left] = [52, 12, 34, 8]; // panel width, plot top and height, y labels
let out = '';
[0.8, 0.5, 0.2].forEach((power, p) => {
const x0 = p * (pw + (FIG_W - 3 * pw) / 2) + left;
const X = (R) => x0 + R * (pw - left - 2);
const Y = (v) => top + plotH * (1 - v);
const trace = (f) => Array.from({ length: 101 }, (_, k) => [X(k / 100), Y(f(k / 100))]);
out += label(x0 - left, 4, `${'ABC'[p]} <tspan font-weight="400">${t({ en: 'Power',
es: 'Potencia' })} ${number(power)}</tspan>`, 3.4, '', palette.navy);
if (!p) out += label(x0 - left, top - 4, t({ en: 'PPV (%)', es: 'VPP (%)' }), 2.8);
for (const v of [0, 0.2, 0.4, 0.6, 0.8, 1]) {
out += line([[X(0), Y(v)], [X(1), Y(v)]], palette.rule, v ? 0.15 : 0.3)
+ label(X(0) - 1.4, Y(v) + 1, v * 100, 2.6, 'text-anchor="end"')
+ label(X(v), Y(0) + 3.6, number(v, v % 1 ? 1 : 0), 2.6, 'text-anchor="middle"');
}
if (dashed) out += line(trace((R) => dashed(power, R)), palette.muted, 0.35,
'stroke-dasharray="1 0.8"');
values.forEach((value, i) => {
out += line(trace((R) => curve(power, R, value)), mix(i / (values.length - 1)), 0.6);
});
out += label(X(0.5), Y(0) + 8, `${t({ en: 'Pre-study odds', es: 'Razón previa' })}, `
+ '<tspan font-style="italic">R</tspan>', 2.9, 'text-anchor="middle"');
});
const key = values.map((value, i) => line([[48 + i * 24, 57.8], [54 + i * 24, 57.8]],
mix(i / (values.length - 1)), 0.8) + label(56 + i * 24, 58.8, `<tspan font-style="italic">`
+ `${name}</tspan> = ${number(value, digits)}`, 2.9)).join('');
return `<svg xmlns="http://www.w3.org/2000/svg" width="${FIG_W * 10}" height="${FIG_H * 10}" `
+ `viewBox="0 0 ${FIG_W} ${FIG_H}">${out}${key}</svg>`;
}
// Eq. (3): n independent studies of equal power, no bias.
const teams = (power, R, n, alpha = 0.05) => (R * (1 - (1 - power) ** n))
/ (R + 1 - (1 - alpha) ** n - R * (1 - power) ** n);
const bandArt = () => `<svg xmlns="http://www.w3.org/2000/svg" width="1400" height="${BAND * 10}" `
+ `viewBox="0 0 140 ${BAND}">${Array.from({ length: 10 }, (_, i) => line(Array.from(
{ length: 81 },
(_, k) => [10 + k * 1.6, 92 - 76 * ppv(0.8, k / 80, i / 10)]), palette.mist, 0.5,
`stroke-opacity="${R2(0.5 - i * 0.04)}"`)).join('')}</svg>`;
تمر كل لوحة على R من 0 إلى 1 بالدالة ppv() نفسها التي تملأ الجدول 4. ورسم المنحنيات من الصيغة يكشف أمرًا يخفيه شكل 2005: منحنياته توافق u = 0 و0.05 و0.20 و0.80، بينما يذكر مفتاحه 0.05 و0.20 و0.50 و0.80. وترسم هذه النسخة قيم المفتاح، وتضيف منحنى انعدام الانحياز متقطعًا، وتذكر ذلك في ملاحظة التعليق. والتسميات نص يحدّد خطَّ التسميات: تمرّر loadSvg الرسم على inlineSvgFonts التي تضمّن هذا الخط من أجل اللوحة، وينضّدها ملف PDF بالخط الذي يقدمه مزوّد الخطوط.
#5 · صفحة أولى وإطار لمقال
const text = (id, content, family, size, color, placement, extra) => ({ kind: 'text', id,
content, fontFamily: family, fontSize: pt(size), color: col(color), align: 'left',
overflow: 'wrap', placement, ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
...(width && { size: { width: mm(width), height: 'auto' } }) });
const caps = (size, fontWeight = 700) => ({ fontWeight, letterSpacing: pt(size * 0.18),
textTransform: 'uppercase' });
const BAND = 100; // mm from the top of the trim to the foot of the band
const titleBlock = { enabled: true, minHeight: mm(BAND + 12 - TOP), slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('navy') },
placement: { anchor: { to: 'bleed', edge: 'top-left' },
size: { width: 'fill', height: mm(BAND + 3) } } }, // + the 3 mm bleed
{ kind: 'image', id: 'curves', resourceId: 'band-art', // Eq. (2), faint, for u = 0 to 0.9
placement: at('page', 'top-left', 128, 46, 76) }, // under the title, clear of the text
text('kicker', '{attr.kicker}', SANS, 8, 'mist', at('page', 'top-left', INNER, 20, 120),
caps(8)),
text('title', '{titleText}', SANS, 36, 'paper', at('#kicker', 'below', 0, 6, 150),
{ fontWeight: 800, lineHeight: 1.02 }),
text('author', '{attr.author}', SERIF, 13, 'paper', at('#title', 'below', 0, 8, 150)),
text('affiliation', '{attr.affiliation}', SANS, 8, 'mist', at('#author', 'below', 0, 1.6, 150),
{ lineHeight: 1.35 }),
text('source', '{attr.source}', SANS, 7.4, 'muted', at('page', 'top-left', INNER, BAND + 4,
MEASURE), { lineHeight: 1.35 }),
] } };
العنوان هو العنوان الوحيد من المستوى الأول؛ ونمطه essay يمتد بعرض الصفحة ويرسم الشريط والتسمية والمؤلف والانتماءات وسطر المصدر من سمات العنوان، فلا تغيّر الطبعة الإسبانية إلا الكلمات. والملخص إطار بعرض الصفحة على أرضية ملونة. والإطار 1، وهو المثال المحلول، يطفو إلى أسفل صفحة بعرض العمودين وينضّد نصه في عمودين داخل الإطار. وتحتفظ النتائج اللازمة بشكلها في الورقة، بالقضية بخط عريض في أول الفقرة: يضع :chip[Corollary 1]{style="corollary"} قبلها تسمية قرمزية صغيرة.
const calloutStyles = [
{ id: 'summary', span: 'page', background: col('tint'), marginTop: pt(0),
marginBottom: pt(LEAD), padding: { top: mm(4), right: mm(6), bottom: mm(4), left: mm(6) },
titleStyle: { fontFamily: SANS, fontSize: pt(8), ...caps(8), color: col('accent'),
gap: mm(1.5) },
body: { fontSize: pt(9.4), lineHeight: pt(13), firstLineIndent: pt(0) } },
{ id: 'box', span: 'page', placement: 'bottom', columnGap: mm(GUTTER),
backgroundEnabled: false, border: { enabled: false },
stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('navy') },
padding: { top: mm(2.5), right: mm(0), bottom: mm(1), left: mm(0) },
marginTop: pt(LEAD), marginBottom: pt(LEAD),
titleStyle: { fontFamily: SANS, fontSize: pt(9), fontWeight: 700, color: col('navy'),
gap: mm(1.2) },
body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.2), firstLineIndent: mm(3) } },
// The journal's first-page note (competing interests, abbreviation) floated to the foot of
// the first column under a hairline, as PLoS Medicine sets it.
{ id: 'note', placement: 'bottom', backgroundEnabled: false, border: { enabled: false },
stripe: { enabled: true, side: 'top', width: pt(0.5), color: col('rule') },
padding: { top: mm(1.6), right: mm(0), bottom: mm(0), left: mm(0) },
marginTop: pt(LEAD), marginBottom: pt(0),
body: { fontFamily: SANS, fontSize: pt(7.6), lineHeight: pt(10.4), color: col('muted'),
boldColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0) } },
];
// :chip[Corollary 1]{style="corollary"}: a label in the sans and the accent, no frame.
const chipStyles = [{ id: 'corollary', fontFamily: SANS, fontSize: em(0.86), bold: true,
color: col('accent'), backgroundEnabled: false, borderWidth: pt(0), paddingX: em(0),
gap: em(0.35) }];
const paragraphStyles = [{ id: 'colophon', fontFamily: SANS, fontSize: pt(7.6),
lineHeight: pt(10.4), color: col('muted'), boldColor: col('ink'), textAlign: 'left',
firstLineIndent: pt(0), spaceBetween: pt(3) }];
ملاحظة الصفحة الأولى في المجلة، أي تضارب المصالح والاختصار، صندوق بنمط note مع placement: 'bottom': ينزل إلى أسفل أول عمود يتسع له، تحت خط رفيع، فينتهي عمودا الصفحة 1 في الطبعة الإنجليزية على ارتفاع واحد. ويسمح headings.balancing.fillShortColumns لفقرة بأن تمتد سطرًا إضافيًا، فينتهي عمودا المراجع في الصفحة الأخيرة متساويين.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 141 · A metascience essay in English and Spanish ═══════
// https://postext.dev/en/cookbook/bilingual-metascience-essay
// Code: MIT · Text: J. P. A. Ioannidis, PLoS Med 2005 (CC BY) · Figures: drawn in code (CC BY 4.0)
// Fonts: Gelasio, Sofia Sans Semi Condensed (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage,
registerCitationEngine, defaultResourceTypes, initMathEngine, parseTSV, mergeCells, setAlignment,
inlineSvgFonts,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'bilingual-metascience-essay';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a navy for the furniture, one vermilion accent, every colour linked
const palette = { ink: '#1c1d24', navy: '#22305a', accent: '#b8442a', tint: '#eceff5',
rule: '#b4bccb', muted: '#5a6070', mist: '#c3cde6', paper: '#ffffff' };
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.navy })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS] = ['Gelasio', 'Sofia Sans Semi Condensed'];
// mm: the 210 × 280 trim, head, foot, inner and outer margins, and the gutter
const [TRIM_W, TRIM_H, TOP, BOTTOM, INNER, OUTER, GUTTER] = [210, 280, 22, 22, 19, 17, 6];
const MEASURE = TRIM_W - INNER - OUTER; // 174 mm across both columns
const [BODY, LEAD] = [9.4, 13]; // pt
const [FIG_W, FIG_H] = [MEASURE, 60]; // mm: Figures 1 and 2, across both columns
// #region answer: one script, two editions: LANG picks the text, the language and the numbers
// The Cookbook composes the pen once per edition: content.<LANG>.md and each named slot
// replace the @content markers. What else follows the language is set here.
const edition = {
// Hyphenation patterns and the words the engine writes (Tabla, Continúa) follow the locale.
locale: t({ en: 'en-us', es: 'es' }),
// Table 1 / Tabla 1, Figure 1 / Figura 1, counted through the essay; tables caption above.
resourceTypes: defaultResourceTypes(LANG).map((type) => ({ ...type, shortLabel: type.name,
numberingTemplate: '{n}', resetOn: 'never',
...(type.id === 'table' && { captionStyle: { position: 'above' } }) })),
// Vancouver numbers in brackets, [2–4]; the CSL locale writes the list's words (2nd ed.,
// 2.ª ed.). The titles of the works stay in English in both editions.
citations: { style: 'elsevier-vancouver', locale: t({ en: 'en-US', es: 'es-ES' }),
marker: 'brackets', collapseRanges: true,
bibliography: { fontSize: em(0.78), lineHeight: pt(9.4), entrySpacing: pt(0.8),
labelWidth: mm(6.4), doi: 'hide' } },
};
// The numbers the script writes (Table 4's PPV, the figure axes) take the edition's decimal
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#ارفع أرقام الاستشهاد
كثيرًا ما تنضّد المجلات الطبية أرقام فانكوفر مرفوعة.
- marker: 'brackets', collapseRanges: true,
+ marker: 'superscript', collapseRanges: true,#اطبع معرّفات DOI
لا يحتفظ BibTeX في هذه الوصفة بمعرّفات DOI، كي يبقى النص البرمجي ضمن حجمه. احتفظ بها في ملفك واطبعها روابط.
- labelWidth: mm(6.4), doi: 'hide' } },
+ labelWidth: mm(6.4), doi: 'link' } },#نضّد الجداول في عمود واحد
جدول 2×2 بصيغ أقصر يتسع له عمود واحد: احذف منه span: 'page'، كما في الجدول 4. وفي ورقة في عمودين بمعادلات مرقمة جدول في عمود واحد.
أخطاء شائعة
خطأ شائع
الرياضيات تحتاج إلى await initMathEngine() قبل البناء الأول
الصيغ التي تُنضَّد قبل أن يعمل محرّك الرياضيات مربعات رمادية نائبة. استورد initMathEngine من https://esm.sh/postext مع سائر الرموز وانتظرها بـ await قبل البناء الأول؛ والمستند الذي فيه رياضيات ويُبنى من دونها يطبع تحذيرًا واحدًا في وحدة التحكم. ومنذ postext 1.5 يأتي MathJax داخل حزمة postext وحدةً واحدة تجلبها initMathEngine، فالاستيراد العادي يعمل من CDN ولا حاجة إلى ?bundle (حتى 1.4 كان يجب أن يأتي كل رمز من https://esm.sh/postext?bundle). استورد من عنوان URL واحد فقط: عنوانان يحمّلان محرّكين. الرياضيات →
خطأ شائع
ملفات Fontsource تغطي الحروف لا الرموز
تضمّن العُدّة ملف latin من Fontsource لكل خط، ومعه ملف latin-ext للحروف č وł و†، وملف greek للحروف α وχ (في عائلة تضمه: لا يضمه Lora ولا Gelasio)، حين يستعملها النص، على الشاشة وفي PDF. أما رموز مثل → و≈ و✓ و★ فليست في أي من هذه الملفات فتغيب عن PDF: ارسمها، أو اكتبها رياضيات، أو اختر خطًا تضمها ملفاته. الخطوط المضمَّنة في PDF →
خطأ شائع
علامة $ المجرّدة تفتح الرياضيات: اكتب \$
علامة الدولار تفتح رياضيات داخل السطر، فسعرٌ مثل $40 يبدأ صيغة. اكتب \$40. الهروب والمحارف الحرفية →
- حيث تتوقف قائمة 2005 عند خمسة مؤلفين ثم et al.، تنتهي قائمة المؤلفين في BibTeX بـ
and others، فيطبعelsevier-vancouverمكانها et al. (منذ postext 1.19؛ كانت الإصدارات السابقة تطبع مؤلفًا مشاركًا اسمه others). - لا تتطابق الصفحات بين الطبعتين: النص الإسباني أطول، فيقع الجدول 4 بعد صفحة. وتنشر اللقطة الصفحات 1 و2 و3 و5 و6 و7 من الطبعتين، كي تبقى الصور دون حد الحجم ويظهر الجدول 4 في كلتيهما.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- “Why Most Published Research Findings Are False”, PLoS Medicine 2(8): e124 (2005), doi:10.1371/journal.pmed.0020124, open access under the Creative Commons Attribution License; abridged, tables and figures redrawn; Spanish translation made for the Cookbook · John P. A. Ioannidis · CC BY
- الخطوط
- Gelasio (SIL OFL 1.1) · Sofia Sans Semi Condensed (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


