باختصار
الفقرتان نفسهما عن فن الطباعة، بالمصادر نفسها، مطبوعتان أربع مرات. كل صفحة تذكر المصادر بطريقة مختلفة، فتتغير الاستشهادات والقائمة في الآخر معها، مع أن النص كُتب مرة واحدة.
ما الذي ستنضده
مقالة من فقرتين عن سبب مرور الطباعة الجيدة دون أن يلاحظها أحد، بستة مصادر: استشهاد سردي، واستشهاد بصفحة، واستشهاد يُسقط المؤلف لأن الجملة تذكره، وعملان يُستشهد بهما معًا. يُنضَّد النص أربع مرات على صفحة 155 × 235 مم، والتغيير الوحيد بين البناءات الأربعة هو citations.style: APA 7، وشيكاغو مؤلف-تاريخ، وIEEE، وISO 690. على كل صفحة اسم الأسلوب في شريط بلون خاص به، فإذا وُضعت الصفحات متجاورة قُرئت جدول مقارنة. تتغير الاستشهادات في شكلها وترتيبها وترقيمها، وتغيّر القائمة ترتيبها وأسماءها، أما المقالة نفسها فهي الملف ذاته.
تجيب هذه الوصفة عن
- كيف أنقل كتابًا من أسلوب استشهاد إلى آخر من دون المساس بالنص؟
- كيف أستشهد بالأعمال وأبني قائمة المراجع بأسلوب APA أو IEEE أو أسلوب استشهاد آخر؟
الجواب المختصر
// Citations are written once, Pandoc's way: [@key], [@a; @b], [-@key] without the author,
// @key [p. 17] inside the sentence. citeproc-js writes them, and the list, in the style named.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const SHOWN = [ // the same text, built once per entry
{ style: 'apa', band: 'apa', name: 'APA 7', system: t({ en: 'author-date', es: 'autor-año' }) },
{ style: 'chicago-author-date', band: 'chicago', name: 'Chicago',
system: t({ en: 'author-date', es: 'autor-año' }) },
{ style: 'ieee', band: 'ieee', name: 'IEEE', system: t({ en: 'numbered', es: 'numérico' }) },
{ style: t({ en: 'iso690-author-date-en', es: 'iso690-author-date-es' }), band: 'iso',
name: 'ISO 690', system: t({ en: 'author-date', es: 'autor-año' }) },
];
const citations = (style) => ({
style, // 'apa' → '(Warde, 1955)'; 'ieee' → '[1]'; the list is sorted and set to match
link: true,
// The authors' names stay whole in the citations, the text and the list: the APA build
// set '(Lup-' | 'ton, 2010)'.
hyphenateNames: false,
bibliography: { fontSize: em(0.85), lineHeight: pt(11.2), hangingIndent: mm(6),
entrySpacing: pt(2), labelWidth: mm(6), doi: 'hide' },
});
المكونات
- الميزات
- الاستشهادات بأسلوب توثيققائمة المراجع من البيانات المرجعيةصفحات افتتاح مصمَّمةلوحة ألوان دلالية
- تستخدم أيضًا
- سمات العنوان
- الخطوط
- Source Serif 4, Source Sans 3 (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · إعداد واحد
الشيفرة هي الجواب المختصر أعلاه. تُكتب الاستشهادات مرة واحدة في المحتوى، بصيغة Pandoc، وتقع المراجع في كتلة BibTeX في الآخر. يحدّد citations.style أسلوب CSL، ومنه يكتب citeproc-js كل استشهاد وكل مدخل: يضع APA فاصلة قبل السنة ويرتب العملين بحسب المؤلف، ويحتفظ شيكاغو بالترتيب الذي كُتبا به، ويحوّلهما IEEE إلى أرقام بترتيب أول استشهاد، ويضع ISO 690 أسماء العائلات في القائمة بحروف كبيرة. وفي كتاب قيد التأليف هذا هو التغيير كله: قيمة واحدة في الإعداد، والنص لا يُمس.
#2 · أربعة بناءات وصفحتان متقابلتان
// The style is set for the whole document, so each style is a build of its own.
const docs = [];
for (at = 0; at < SHOWN.length; at++) {
// pageIndexOffset makes each page the next one of a book, so the desk pairs them:
// APA beside Chicago, IEEE beside ISO 690.
const content = { markdown, continuation: { pageIndexOffset: at + 1 } };
docs.push(await buildDocumentWithFonts(content, config(), kitFonts(FONTS)));
}
الأسلوب يسري على المستند كله، لذا فالنسخ الأربع أربعة بناءات لـ Markdown نفسه. يأخذ كل منها pageIndexOffset أعلى بواحد من سابقه، فتصير صفحته الصفحة التالية من كتاب متخيَّل؛ ثم تجمعها طاولة العرض في صفحتين متقابلتين مرتين، والأسلوبان مؤلف-تاريخ الأقل اختلافًا متجاوران.
#3 · اسم الأسلوب في شريط
// The kicker names the build's citation style: a label of the design (#849).
const kicker = (s, i) => `${t({ en: 'Citation style', es: 'Estilo de cita' })}`
+ ` · ${i + 1} / ${SHOWN.length} · ${s.system}`;
const opener = (s, i) => ({
enabled: true,
minHeight: mm(41), // from the top margin to under the title, 63 mm from the trim
slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col(s.band) },
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: 'fill', height: mm(44) } } },
{ kind: 'text', id: 'kicker', content: kicker(s, i), fontFamily: SANS, fontSize: pt(8),
fontWeight: 600, letterSpacing: pt(1.4), textTransform: 'uppercase', color: col('paper'),
align: 'left',
placement: { anchor: { to: 'page', edge: 'top-left' }, offset: { x: mm(18), y: mm(12) } } },
{ kind: 'text', id: 'name', content: s.name, fontFamily: SERIF, fontSize: pt(54),
fontWeight: 600, lineHeight: 1, color: col('paper'), align: 'left', overflow: 'clip',
placement: { anchor: { to: '#kicker', edge: 'below' }, offset: { x: mm(0), y: mm(5) },
size: { width: mm(119), height: 'auto' } } },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: SERIF, fontSize: pt(20),
fontWeight: 600, lineHeight: 1.15, color: col('ink'), align: 'left', overflow: 'wrap',
placement: { anchor: { to: 'page', edge: 'top-left' }, offset: { x: mm(18), y: mm(52) },
size: { width: mm(119), height: 'auto' } } },
] },
});
يرسم تصميم العنوان الشريطَ من حدّ القص، والعنوانَ التمهيدي برقم الأسلوب ونظامه، والاسمَ بحجم 54 pt. ويأتي الاسم والنظام من النص البرمجي لا من Markdown، لأن النص واحد في المستندات الأربعة.
const palette = {
ink: '#1d1b19', muted: '#66605a', rule: '#cfc8bf', paper: '#ffffff',
apa: '#2f5d8a', chicago: '#8c2f2b', ieee: '#24476b', iso: '#3c6b4f', // the four bands
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// Each document points main-color at its own band, so any default left follows it.
const colorPalette = (band) => Object.entries({ ...palette, 'main-color': palette[band] })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
يوجّه كل مستند main-color إلى شريطه، فتكون الألوان الأربعة مداخل مربوطة في لوحة الألوان، وتتبع كل قيمة افتراضية لا يذكرها الإعداد شريطَ صفحتها.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 093 · One text in four citation styles ════════════════
// https://postext.dev/en/cookbook/one-text-four-citation-styles
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.34.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine,
} from 'https://esm.sh/postext';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'one-text-four-citation-styles';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: one ink, and a colour for each style's band
const palette = {
ink: '#1d1b19', muted: '#66605a', rule: '#cfc8bf', paper: '#ffffff',
apa: '#2f5d8a', chicago: '#8c2f2b', ieee: '#24476b', iso: '#3c6b4f', // the four bands
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// Each document points main-color at its own band, so any default left follows it.
const colorPalette = (band) => Object.entries({ ...palette, 'main-color': palette[band] })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS] = ['Source Serif 4', 'Source Sans 3'];
const LEAD = 14; // pt
// #region answer: the style is one setting; everything else stays the same
// Citations are written once, Pandoc's way: [@key], [@a; @b], [-@key] without the author,
// @key [p. 17] inside the sentence. citeproc-js writes them, and the list, in the style named.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const SHOWN = [ // the same text, built once per entry
{ style: 'apa', band: 'apa', name: 'APA 7', system: t({ en: 'author-date', es: 'autor-año' }) },
{ style: 'chicago-author-date', band: 'chicago', name: 'Chicago',
system: t({ en: 'author-date', es: 'autor-año' }) },
{ style: 'ieee', band: 'ieee', name: 'IEEE', system: t({ en: 'numbered', es: 'numérico' }) },
{ style: t({ en: 'iso690-author-date-en', es: 'iso690-author-date-es' }), band: 'iso',
name: 'ISO 690', system: t({ en: 'author-date', es: 'autor-año' }) },
];
const citations = (style) => ({
style, // 'apa' → '(Warde, 1955)'; 'ieee' → '[1]'; the list is sorted and set to match
link: true,
// The authors' names stay whole in the citations, the text and the list: the APA build
// set '(Lup-' | 'ton, 2010)'.
hyphenateNames: false,
bibliography: { fontSize: em(0.85), lineHeight: pt(11.2), hangingIndent: mm(6),
entrySpacing: pt(2), labelWidth: mm(6), doi: 'hide' },
});
// #endregion
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#جرّب أسلوب حواشٍ
مع أسلوب شيكاغو للحواشي والببليوغرافيا يصير كل استشهاد حاشية سفلية والقائمة ببليوغرافيا؛ والنص لا يتغير مع ذلك.
- { style: 'apa', band: 'apa', name: 'APA 7', system: t({ en: 'author-date', es: 'autor-año' }) },
+ { style: 'chicago-notes-bibliography', band: 'apa', name: 'Chicago', system: 'notes' },#اكتب الأرقام مرتفعة
يستطيع الأسلوب المرقم أن يحتفظ بقائمته ويطبع الاستشهادات أرقامًا مرتفعة، كما تفعل Nature وفانكوفر.
- link: true,
+ link: true, marker: 'superscript',أخطاء شائعة
- يُكتب محدِّد الموضع مرة واحدة ويطبع كل أسلوب كلمته الخاصة له: «p. 17» في الأساليب الأربعة هنا. أما أسلوب ISO 690 الإسباني المضمَّن فيطبع «p.» لكل نوع من محدِّدات الموضع، بما فيها القسم والفصل، ولهذا يستشهد هذا النص بصفحة.
- أرقام الطبعات تُكتب في BibTeX أرقامًا (
edition = {3}): فيكتب كل أسلوب «3rd ed.» أو «3.ª ed.» أو «3.» على طريقته. وإذا كُتبت «3rd» طُبعت الكلمة كما هي وضاعت صيغة الأسلوب.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- نص أصلي, CC BY 4.0
- الخطوط
- Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


