# Ένα δοκίμιο μεταεπιστήμης στα αγγλικά και στα ισπανικά

> Το δοκίμιο του Ιωαννίδη (2005) από ένα σενάριο σε δύο εκδόσεις, με τύπους σε κείμενο και κελιά πινάκων, και την Figure 1 σχεδιασμένη από την εξίσωσή της.

- Έκδοση HTML: https://postext.dev/el/cookbook/bilingual-metascience-essay
- Συνταγή Αρ. 141 · Πίνακες · Επίπεδο 3 (Προχωρημένο) · Έξοδοι: Canvas, PDF
- Είδη: Επιστημονικά άρθρα και ακαδημαϊκά κείμενα
- Απαιτεί postext ≥ 1.65.0, postext-pdf ≥ 1.65.0 · δοκιμασμένη με 1.65.0, postext-pdf 1.65.0 στις 2026-10-31
- Σελίδες: [1](https://postext.dev/cookbook/bilingual-metascience-essay/en/p01.webp?v=807a2293), [2](https://postext.dev/cookbook/bilingual-metascience-essay/en/p02.webp?v=807a2293), [3](https://postext.dev/cookbook/bilingual-metascience-essay/en/p03.webp?v=807a2293), [5](https://postext.dev/cookbook/bilingual-metascience-essay/en/p05.webp?v=807a2293), [6](https://postext.dev/cookbook/bilingual-metascience-essay/en/p06.webp?v=807a2293), [7](https://postext.dev/cookbook/bilingual-metascience-essay/en/p07.webp?v=807a2293)
- PDF: https://postext.dev/cookbook/bilingual-metascience-essay/en/bilingual-metascience-essay.pdf?v=807a2293
- Άνοιγμα στο Sandbox: https://postext.dev/el/sandbox#recipe=bilingual-metascience-essay&lang=en (.postext: https://postext.dev/cookbook/bilingual-metascience-essay/en/bilingual-metascience-essay.postext)
- Τελευταία ενημέρωση: 2026-10-31
- Άλλες γλώσσες: [en](https://postext.dev/en/cookbook/bilingual-metascience-essay.md), [es](https://postext.dev/es/cookbook/bilingual-metascience-essay.md), [ca](https://postext.dev/ca/cookbook/bilingual-metascience-essay.md), [de](https://postext.dev/de/cookbook/bilingual-metascience-essay.md), [fr](https://postext.dev/fr/cookbook/bilingual-metascience-essay.md), [it](https://postext.dev/it/cookbook/bilingual-metascience-essay.md), [pt](https://postext.dev/pt/cookbook/bilingual-metascience-essay.md), [zh](https://postext.dev/zh/cookbook/bilingual-metascience-essay.md), [ja](https://postext.dev/ja/cookbook/bilingual-metascience-essay.md), [ar](https://postext.dev/ar/cookbook/bilingual-metascience-essay.md)

## Με λίγα λόγια

Ένα διάσημο δοκίμιο ανοιχτής πρόσβασης για το γιατί πολλά ερευνητικά ευρήματα δεν αντέχουν, ως ανατύπωση επτά σελίδων. Ένα σενάριο φτιάχνει αγγλική έκδοση και ισπανική μετάφραση, με δικό τους συλλαβισμό, δεκαδικό κόμμα και ετικέτες.

## Τι θα στοιχειοθετήσετε

Μια ανατύπωση επτά σελίδων του δοκιμίου του John Ioannidis *Why Most Published Research Findings Are False* (PLoS Medicine, 2005), συντομευμένου και στοιχειοθετημένου σε σελίδα 210 × 280 mm με δύο στήλες. Μια σκούρα μπλε ζώνη ανοίγει την πρώτη σελίδα, με τις καμπύλες του ίδιου του τύπου του δοκιμίου σχεδιασμένες αχνά πίσω από τον τίτλο. Οι τρεις τύποι είναι αριθμημένοι τύποι προβολής· οι πίνακες 2×2 φέρουν έναν τύπο σε κάθε κελί, με πραγματικά α και β· η Figure 1 υπολογίζεται από την Eq. (2), και η τελευταία στήλη του Table 4 από την ίδια εξίσωση. Το ίδιο σενάριο φτιάχνει μια ισπανική μετάφραση με ισπανικό συλλαβισμό, δεκαδικά κόμματα στους πίνακες και στις εικόνες, εισαγωγικά « » και ετικέτες στα ισπανικά. Ακολουθούν τριάντα τρεις αναφορές σε στιλ Vancouver, ξαναφτιαγμένες ως BibTeX από τον κατάλογο του άρθρου.

**Αυτή η συνταγή απαντά:**

- Πώς δημοσιεύω ένα άρθρο σε δύο γλώσσες από ένα σενάριο, με την τυπογραφία κάθε γλώσσας;
- Πώς φτιάχνω πίνακα με γραμμές κεφαλίδας, συγχωνευμένα κελιά, πλάτη στηλών και στοίχιση ανά κελί;
- Πώς στοιχειοθετώ μαθηματικά (μέσα στο κείμενο, σε απομονωμένη θέση, εξισώσεις) και τα κρατώ διανυσματικά στο PDF;
- Πώς ξαναστοιχειοθετώ με το Postext μια εργασία ανοικτής πρόσβασης από το arXiv ή το PubMed Central, κρατώντας τις βιβλιογραφικές παραπομπές, τις εικόνες και τη γραμμή άδειας;

## Η σύντομη απάντηση

```js
// script.js, γραμμές 32–54
// The Cookbook composes the pen once per edition: content.<LANG>.md and each named slot
// replace the @content markers. What else follows the language is set here.
const edition = {
  // Hyphenation patterns and the words the engine writes (Tabla, Continúa) follow the locale.
  locale: t({ en: 'en-us', es: 'es' }),
  // Table 1 / Tabla 1, Figure 1 / Figura 1, counted through the essay; tables caption above.
  resourceTypes: defaultResourceTypes(LANG).map((type) => ({ ...type, shortLabel: type.name,
    numberingTemplate: '{n}', resetOn: 'never',
    ...(type.id === 'table' && { captionStyle: { position: 'above' } }) })),
  // Vancouver numbers in brackets, [2–4]; the CSL locale writes the list's words (2nd ed.,
  // 2.ª ed.). The titles of the works stay in English in both editions.
  citations: { style: 'elsevier-vancouver', locale: t({ en: 'en-US', es: 'es-ES' }),
    marker: 'brackets', collapseRanges: true,
    bibliography: { fontSize: em(0.78), lineHeight: pt(9.4), entrySpacing: pt(0.8),
      labelWidth: mm(6.4), doi: 'hide' } },
};
// The numbers the script writes (Table 4's PPV, the figure axes) take the edition's decimal
// sign, 0.85 or 0,85. Formulas keep their symbols; content.es.md writes 0{,}05 inside $…$
// so that TeX sets no space after the comma.
const number = (x, digits = 2) => x.toLocaleString(t({ en: 'en-US', es: 'es-ES' }),
  { minimumFractionDigits: digits, maximumFractionDigits: digits });
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
await initMathEngine(); // before the tables are built (gotcha: math-bundle)
```

## Υλικά

**Διδάσκει**

- [Μαθηματικά](https://postext.dev/el/docs/document-format-inline.md#μαθηματικοί-τύποι): LaTeX μέσα στη γραμμή και σε ξεχωριστή γραμμή, στοιχειοθετημένο από το MathJax, πάνω στο πλέγμα και διανυσματικό σε κάθε έξοδο, με χημεία μέσω του mhchem.
- [Πίνακες από δεδομένα](https://postext.dev/el/docs/document-format-resources.md#ενσωμάτωση-μπλοκ-προαιρετική-ρητή-τοποθέτηση-μέσα-στη-ροή): Πόροι πίνακα με γραμμές κεφαλίδας, συγχωνευμένα κελιά, αναλογίες στηλών, στοίχιση ανά κελί και λίστες μέσα στα κελιά· οι πίνακες με κάθετες γραμμές του Markdown δεν αναλύονται.
- [Συλλαβισμός και γλώσσα του εγγράφου](https://postext.dev/el/docs/justification.md#υποστηριζόμενες-γλώσσες): Συλλαβισμός από μοτίβα TeX σε εννέα γλώσσες, μεταξύ τους και τα ελληνικά, που επιλέγεται από τη γλώσσα του εγγράφου· η γλώσσα ορίζει επίσης τα κείμενα συνέχειας των πινάκων και τη γλώσσα του PDF με ετικέτες.

**Χρησιμοποιεί επίσης**

- [Στιλ πίνακα](https://postext.dev/el/docs/configuration-resources.md#στιλ-πίνακα)
- [Εικόνα και Πίνακας στη γλώσσα σας](https://postext.dev/el/docs/configuration-resources.md#τύποι-πόρων)
- [Βιβλιογραφικές παραπομπές σε στιλ παραπομπών](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία)
- [Βιβλιογραφία από τις αναφορές](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία)
- [Εικόνες και πίνακες ως πόροι](https://postext.dev/el/docs/document-format-resources.md#πόροι)
- [Παραπομπές που τοποθετούν εικόνες](https://postext.dev/el/docs/document-format-resources.md#παραπομπή-μέσα-στο-κείμενο-η-κύρια-μορφή)
- [Αριθμημένες λεζάντες](https://postext.dev/el/docs/document-format-resources.md#αρίθμηση-κατά-την-πρώτη-παραπομπή)
- [Τοποθέτηση εικόνων](https://postext.dev/el/docs/document-format-resources.md#τοποθέτηση)
- [Στιλ λεζάντας](https://postext.dev/el/docs/configuration-resources.md#στιλ-λεζάντας)
- [Σχεδιασμένες εναρκτήριες σελίδες](https://postext.dev/el/docs/configuration-headings.md#πλάτος-και-προηγμένη-σχεδίαση)
- [Ιδιότητες επικεφαλίδων](https://postext.dev/el/docs/document-format.md#χαρακτηριστικά-επικεφαλίδων)
- [Πλαίσια σε όλο το πλάτος της σελίδας](https://postext.dev/el/docs/configuration-callouts.md#ο-περιέκτης-callout)
- [Πλαίσια σημειώσεων](https://postext.dev/el/docs/configuration-callouts.md#στιλ-πλαισίων)
- [Κινητά πλαίσια](https://postext.dev/el/docs/configuration-callouts.md#ο-περιέκτης-callout)
- [Γέμισμα κοντών στηλών](https://postext.dev/el/docs/configuration-page-flow.md#εξισορρόπηση-στηλών)
- [Ετικέτες μέσα στη γραμμή](https://postext.dev/el/docs/configuration-styles.md#στιλ-ετικετών)
- [Εξαγωγή PDF](https://postext.dev/el/docs/configuration-pdf-output.md#παραγωγή-pdf)
- [Στήλες σε πλαίσιο ή στο κείμενο](https://postext.dev/el/docs/document-format-directives.md#columns)
- [Εξισορρόπηση στηλών](https://postext.dev/el/docs/configuration-page-flow.md#εξισορρόπηση-στηλών)
- [Στιλ επικεφαλίδων](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)
- [Κεφαλίδες ανά ρόλο σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου)
- [Στιλ παραγράφων](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων)
- [Γραμματοσειρές ενσωματωμένες στο PDF](https://postext.dev/el/docs/configuration-pdf-output.md#γιατί-πάροχος-γραμματοσειρών)
- [Προσαρμοσμένοι τύποι πόρων](https://postext.dev/el/docs/configuration-resources.md#τύποι-πόρων)
- [Εκθέτες και δείκτες](https://postext.dev/el/docs/document-format-inline.md#μορφοποίηση-μέσα-στη-γραμμή)
- [Κεφάλαια χωρίς αρίθμηση](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)

**Η διαμόρφωση με μια ματιά**

- [`bodyText`](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο), [`calloutStyles`](https://postext.dev/el/docs/configuration-callouts.md#στιλ-πλαισίων), [`captionStyle`](https://postext.dev/el/docs/configuration-resources.md#στιλ-λεζάντας), [`checks`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#έλεγχος-περιεχομένου-διαμόρφωση), [`chipStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-ετικετών), [`citations`](https://postext.dev/el/docs/configuration-notes-references.md#βιβλιογραφικές-παραπομπές), [`colorPalette`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων), [`footer`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`header`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`headingStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων), [`headings`](https://postext.dev/el/docs/configuration-headings.md#επικεφαλίδες), [`layout`](https://postext.dev/el/docs/configuration-page-layout.md#διάταξη), [`locale`](https://postext.dev/el/docs/configuration-language.md#συλλαβισμός), [`math`](https://postext.dev/el/docs/configuration-lists-math.md#μαθηματικά), [`page`](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα), [`paragraphStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων), [`resourceTypes`](https://postext.dev/el/docs/configuration-resources.md#τύποι-πόρων), [`tableStyle`](https://postext.dev/el/docs/configuration-resources.md#στιλ-πίνακα)

**API**

- [`LOCALES`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`STYLES`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`buildDocumentWithFonts`](https://postext.dev/el/docs/configuration-programmatic-usage.md#φόρτωση-γραμματοσειρών-πριν-από-τη-σελιδοποίηση), [`createCiteprocEngine`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`decompressWoff2`](https://postext.dev/el/docs/configuration-pdf-output.md#πάροχος-γραμματοσειρών-για-τον-browser-fontsource--woff2), [`defaultResourceTypes`](https://postext.dev/el/docs/configuration-resources.md#τύποι-πόρων), [`initMathEngine`](https://postext.dev/el/docs/document-format-inline.md#μαθηματικοί-τύποι), [`inlineSvgFonts`](https://postext.dev/el/docs/configuration-resources.md#γραμματοσειρές-στο-κείμενο-svg), [`mergeCells`](https://postext.dev/el/docs/document-format-resources.md#ενσωμάτωση-μπλοκ-προαιρετική-ρητή-τοποθέτηση-μέσα-στη-ροή), [`parseTSV`](https://postext.dev/el/docs/document-format-resources.md#ενσωμάτωση-μπλοκ-προαιρετική-ρητή-τοποθέτηση-μέσα-στη-ροή), [`prepareFonts`](https://postext.dev/el/docs/configuration-programmatic-usage.md#φόρτωση-γραμματοσειρών-πριν-από-τη-σελιδοποίηση), [`registerCitationEngine`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`registerResourceImage`](https://postext.dev/el/docs/architecture.md#η-επιφάνεια-του-api), [`renderPageToCanvas`](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap), [`renderToPdf`](https://postext.dev/el/docs/configuration-pdf-output.md#παραγωγή-pdf), [`setAlignment`](https://postext.dev/el/docs/document-format-resources.md#ενσωμάτωση-μπλοκ-προαιρετική-ρητή-τοποθέτηση-μέσα-στη-ροή)

**Γραμματοσειρές**

- Gelasio (OFL-1.1), Sofia Sans Semi Condensed (OFL-1.1)

## Προετοιμασία

### 1 · Ένα σενάριο, δύο εκδόσεις

Ο κώδικας είναι η [σύντομη απάντηση](https://postext.dev/el/cookbook/bilingual-metascience-essay.md#η-σύντομη-απάντηση) παραπάνω. Το Συνταγολόγιο συνθέτει το pen μία φορά για κάθε γλώσσα και βάζει το `content.en.md` ή το `content.es.md` εκεί όπου βρίσκεται η ένδειξη `@content`· κάθε επώνυμη θέση (`content.corollaries.es.md`, `content.resources.es.md`) ακολουθεί τον ίδιο κανόνα, και μια θέση χωρίς ισπανικό αρχείο καταφεύγει στα αγγλικά, έτσι οι δύο εκδόσεις μοιράζονται ένα αρχείο BibTeX. Ό,τι άλλο αλλάζει με τη γλώσσα περνά από το `LANG`: το `locale` επιλέγει τα μοτίβα συλλαβισμού (το `'es'` είναι ο κωδικός που συλλαβίζει ισπανικά), το `defaultResourceTypes(LANG)` γράφει *Tabla* και *Figura*, η locale CSL γράφει τις λέξεις του καταλόγου αναφορών, και το `toLocaleString` δίνει στους αριθμούς που υπολογίζει το σενάριο το δεκαδικό τους κόμμα. Η μετάφραση είναι γραμμένη με ισπανική τυπογραφία: εισαγωγικά « », *0,05* στο κείμενο και `0{,}05` μέσα σε τύπο, ώστε το TeX να μη στοιχειοθετήσει το κόμμα ως σημείο στίξης με διάστημα μετά. Για να δημοσιεύσετε το δικό σας άρθρο σε δύο γλώσσες, κρατήστε ένα αρχείο ανά γλώσσα για το κείμενο και τις λεζάντες, και βάλτε κάθε άλλη διαφορά σε ένα αντικείμενο όπως το `edition`.

### 2 · Τύποι μέσα στα κελιά των πινάκων

```js
// script.js, γραμμές 414–439
// A cell, a caption or a note sets $…$ as the text does (postext ≥ 1.19): MathJax paths at
// the cell's 8 pt, on the baseline of its line and aligned with the cell, vector in the PDF.
// The faces' latin files have no α or β (gotcha: latin-subset); the formulas need none.
const [CELL_PT, PAD] = [8, 1]; // cell type (pt), cell padding (mm)
function tableModel(tsv, widths, headerRows, merges = [], right = []) {
  let model = { ...parseTSV(tsv, { headerRows }), columnWidths: widths };
  model.rows.forEach((_, row) => right.forEach((c) => {
    model = setAlignment(model, { row, col: c }, 'right'); // the numbers, the PPV and their heads
  }));
  for (const range of merges) model = mergeCells(model, range); // gotcha: merged-cells-hiddenby
  return model;
}
// "Research finding" over both header rows, "True relationship" over Yes, No and Total.
const twoByTwo = (tsv) => tableModel(tsv, [1.1, 1.6, 1.6, 2.5], 2, [
  { start: { row: 0, col: 0 }, end: { row: 1, col: 0 } },
  { start: { row: 0, col: 1 }, end: { row: 0, col: 3 } }]);
// Table 4's last column is computed from Eq. (2), α = 0.05: two significant figures, as in 2005.
const ppv = (power, R, u, alpha = 0.05) => (power * R + u * (1 - power) * R)
  / (R + alpha - (1 - power) * R + u - u * alpha + u * (1 - power) * R);
const read = (s) => Number(s.replace(',', '.'));
const odds = (s) => s.split(':').map((x) => Number(x.replace(/\D/g, ''))).reduce((a, b) => a / b);
const ppvRows = (tsv) => tsv.split('\n').map((line, r) => {
  const [power, R, u, example, head] = line.split('\t');
  const p = ppv(read(power), odds(R), read(u)); // 0.0010: as many decimals as 2 figures need
  return [power, R, u, example, r ? number(p, 1 - Math.floor(Math.log10(p))) : head].join('\t');
}).join('\n');
```

Ένα κελί πίνακα στοιχειοθετεί το `$…$` όπως και το κείμενο (από το postext 1.19), έτσι ένα κελί που γράφει `$c(1-\beta)R/(R+1)$` στο TSV είναι τύπος: διαδρομές MathJax στα 8 pt των κελιών, πάνω στη γραμμή βάσης της γραμμής του κελιού, έτσι τα *Yes*, *No* και οι τύποι στέκονται σε μία γραμμή, και διανυσματικά περιγράμματα στο PDF. Τα λατινικά αρχεία του Fontsource δεν έχουν ελληνικά γράμματα, και οι τύποι δεν χρειάζονται κανένα. Και οι λεζάντες και οι σημειώσεις δέχονται μαθηματικά: η λεζάντα του Table 4 ονομάζει την ισχύ 1 − β και η σημείωσή του υποθέτει α = 0.05, όπως τα τυπώνει το άρθρο του 2005. Το `setAlignment` στοιχίζει δεξιά τους αριθμούς του Table 4, και το `mergeCells` ενώνει το *Research finding* πάνω από τις δύο σειρές κεφαλίδας και το *True relationship* πάνω από τρεις στήλες· γράφει επίσης τα κρυφά κελιά κράτησης θέσης που χρειάζεται ένα συγχωνευμένο κελί.

### 3 · Λεζάντες και πίνακες από τη θέση, αριθμοί από τον τύπο

```js
// script.js, γραμμές 443–471
const parsed = blocks.trim().split(/\n\s*\n/).map((block) => {
  const fields = {};
  const tsv = block.split('\n').filter((line) => {
    const m = /^(id|caption|note|alt): (.*)$/.exec(line);
    if (m) fields[m[1]] = m[2];
    return !m;
  }).join('\n');
  return { ...fields, tsv };
});
const tables = parsed.filter((b) => b.tsv).map(({ id, caption, note, tsv }) => {
  const model = id === 'tbl-ppv'
    ? tableModel(ppvRows(tsv), [0.8, 0.95, 0.75, 3.8, 1.05], 1, [], [0, 1, 2, 4])
    : twoByTwo(tsv);
  return { id, typeId: 'table', kind: 'table', createdAt: 0, updatedAt: 0, caption, note,
    table: { model }, placement: { position: 'auto', ...(id !== 'tbl-ppv' && { span: 'page' }) } };
});
const figures = parsed.filter((b) => !b.tsv).map(({ id, caption, note, alt }) => ({ id,
  typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0, caption, note, altText: alt,
  placement: { position: 'auto', span: 'page' },
  svg: { fileId: `${id}.svg`, width: FIG_W * 10, height: FIG_H * 10 } }));
const resources = [...tables, ...figures,
  { id: 'band-art', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
    svg: { fileId: 'band-art.svg', width: 1400, height: BAND * 10 } }];
const tableStyle = { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
  headerBackground: col('navy'), headerColor: col('paper'), headerBold: true,
  headerFontFamily: SANS, headerFontSize: pt(CELL_PT), bodyFontFamily: SANS,
  bodyFontSize: pt(CELL_PT), bodyColor: col('ink'), cellPadding: mm(PAD) };
const captionStyle = { fontFamily: SANS, fontSize: pt(8.2), color: col('ink'), labelBold: true,
  labelColor: col('accent'), gap: mm(2), note: { fontSize: pt(7), color: col('muted') } };
```

Οι πίνακες, οι λεζάντες, οι σημειώσεις και τα εναλλακτικά κείμενα βρίσκονται στο `content.resources.<lang>.md`, ένα μπλοκ το καθένα, έτσι ένας μεταφραστής επεξεργάζεται μόνο αρχεία κειμένου και κάθε έκδοση φέρει μόνο τη δική της γλώσσα. Η στήλη PPV του Table 4 δεν πληκτρολογείται: η `ppv()` την υπολογίζει από την ισχύ, το *R* και το *u* κάθε σειράς, και οι εννέα τιμές συμφωνούν με όσες τυπώθηκαν το 2005 σε δύο σημαντικά ψηφία. Οι πίνακες είναι κινητά στοιχεία με `position: 'auto'`, έτσι ο Table 1 μπορεί να πάρει το κάτω μέρος της σελίδας που τον αναφέρει αντί να στοιβαχτεί με τα άλλα κινητά στοιχεία στην επόμενη.

### 4 · Η Figure 1 σχεδιασμένη από την Eq. (2)

```js
// script.js, γραμμές 475–524
const R2 = (x) => Math.round(x * 100) / 100;
// Each label names the label face: loadSvg embeds it for the canvas (inlineSvgFonts), and the
// PDF asks the provider for it.
const mix = (f) => `#${[1, 3, 5].map((i) => Math.round(parseInt(palette.navy.slice(i, i + 2), 16)
  * (1 - f) + parseInt(palette.accent.slice(i, i + 2), 16) * f).toString(16).padStart(2, '0'))
  .join('')}`; // navy for the first curve, vermilion for the last
const label = (x, y, s, size, extra = '', fill = palette.muted) => `<text x="${R2(x)}" `
  + `y="${R2(y)}" font-size="${size}" font-family="${SANS}" fill="${fill}" ${extra}>${s}</text>`;
const line = (points, stroke, width, extra = '') => `<path d="M${points.map(([x, y]) =>
  `${R2(x)} ${R2(y)}`).join('L')}" fill="none" stroke="${stroke}" stroke-width="${width}" `
  + `${extra}/>`;
// Three panels, power 0.80, 0.50 and 0.20; PPV in % against R from 0 to 1, one curve per value.
function panels(curve, values, name, digits, dashed) {
  const [pw, top, plotH, left] = [52, 12, 34, 8]; // panel width, plot top and height, y labels
  let out = '';
  [0.8, 0.5, 0.2].forEach((power, p) => {
    const x0 = p * (pw + (FIG_W - 3 * pw) / 2) + left;
    const X = (R) => x0 + R * (pw - left - 2);
    const Y = (v) => top + plotH * (1 - v);
    const trace = (f) => Array.from({ length: 101 }, (_, k) => [X(k / 100), Y(f(k / 100))]);
    out += label(x0 - left, 4, `${'ABC'[p]}  <tspan font-weight="400">${t({ en: 'Power',
      es: 'Potencia' })} ${number(power)}</tspan>`, 3.4, '', palette.navy);
    if (!p) out += label(x0 - left, top - 4, t({ en: 'PPV (%)', es: 'VPP (%)' }), 2.8);
    for (const v of [0, 0.2, 0.4, 0.6, 0.8, 1]) {
      out += line([[X(0), Y(v)], [X(1), Y(v)]], palette.rule, v ? 0.15 : 0.3)
        + label(X(0) - 1.4, Y(v) + 1, v * 100, 2.6, 'text-anchor="end"')
        + label(X(v), Y(0) + 3.6, number(v, v % 1 ? 1 : 0), 2.6, 'text-anchor="middle"');
    }
    if (dashed) out += line(trace((R) => dashed(power, R)), palette.muted, 0.35,
      'stroke-dasharray="1 0.8"');
    values.forEach((value, i) => {
      out += line(trace((R) => curve(power, R, value)), mix(i / (values.length - 1)), 0.6);
    });
    out += label(X(0.5), Y(0) + 8, `${t({ en: 'Pre-study odds', es: 'Razón previa' })}, `
      + '<tspan font-style="italic">R</tspan>', 2.9, 'text-anchor="middle"');
  });
  const key = values.map((value, i) => line([[48 + i * 24, 57.8], [54 + i * 24, 57.8]],
    mix(i / (values.length - 1)), 0.8) + label(56 + i * 24, 58.8, `<tspan font-style="italic">`
    + `${name}</tspan> = ${number(value, digits)}`, 2.9)).join('');
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${FIG_W * 10}" height="${FIG_H * 10}" `
    + `viewBox="0 0 ${FIG_W} ${FIG_H}">${out}${key}</svg>`;
}
// Eq. (3): n independent studies of equal power, no bias.
const teams = (power, R, n, alpha = 0.05) => (R * (1 - (1 - power) ** n))
  / (R + 1 - (1 - alpha) ** n - R * (1 - power) ** n);
const bandArt = () => `<svg xmlns="http://www.w3.org/2000/svg" width="1400" height="${BAND * 10}" `
  + `viewBox="0 0 140 ${BAND}">${Array.from({ length: 10 }, (_, i) => line(Array.from(
    { length: 81 },
    (_, k) => [10 + k * 1.6, 92 - 76 * ppv(0.8, k / 80, i / 10)]), palette.mist, 0.5,
  `stroke-opacity="${R2(0.5 - i * 0.04)}"`)).join('')}</svg>`;
```

Κάθε τμήμα είναι ένας βρόχος πάνω στο *R* από 0 έως 1 μέσα από την ίδια `ppv()` που γεμίζει τον Table 4. Όταν οι καμπύλες σχεδιάζονται από τον τύπο, φαίνεται κάτι που κρύβει η εικόνα του 2005: οι καμπύλες της αντιστοιχούν σε *u* = 0, 0.05, 0.20 και 0.80, ενώ το υπόμνημά της λέει 0.05, 0.20, 0.50 και 0.80. Αυτή η εκδοχή σχεδιάζει τις τιμές του υπομνήματος και προσθέτει τη μηδενική μεροληψία ως διακεκομμένη καμπύλη, και η σημείωση της λεζάντας το αναφέρει. Οι ετικέτες είναι κείμενο που ονομάζει τη γραμματοσειρά των ετικετών: η `loadSvg` περνά το σχέδιο από την `inlineSvgFonts`, που ενσωματώνει αυτή τη γραμματοσειρά για τον καμβά, και το PDF τις στοιχειοθετεί στη γραμματοσειρά που δίνει ο πάροχος.

### 5 · Μια πρώτη σελίδα και ένα πλαίσιο για ένα δοκίμιο

```js
// script.js, γραμμές 58–81
const text = (id, content, family, size, color, placement, extra) => ({ kind: 'text', id,
  content, fontFamily: family, fontSize: pt(size), color: col(color), align: 'left',
  overflow: 'wrap', placement, ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
  ...(width && { size: { width: mm(width), height: 'auto' } }) });
const caps = (size, fontWeight = 700) => ({ fontWeight, letterSpacing: pt(size * 0.18),
  textTransform: 'uppercase' });
const BAND = 100; // mm from the top of the trim to the foot of the band
const titleBlock = { enabled: true, minHeight: mm(BAND + 12 - TOP), slot: { elements: [
  { kind: 'box', id: 'band', style: { backgroundColor: col('navy') },
    placement: { anchor: { to: 'bleed', edge: 'top-left' },
      size: { width: 'fill', height: mm(BAND + 3) } } }, // + the 3 mm bleed
  { kind: 'image', id: 'curves', resourceId: 'band-art', // Eq. (2), faint, for u = 0 to 0.9
    placement: at('page', 'top-left', 128, 46, 76) }, // under the title, clear of the text
  text('kicker', '{attr.kicker}', SANS, 8, 'mist', at('page', 'top-left', INNER, 20, 120),
    caps(8)),
  text('title', '{titleText}', SANS, 36, 'paper', at('#kicker', 'below', 0, 6, 150),
    { fontWeight: 800, lineHeight: 1.02 }),
  text('author', '{attr.author}', SERIF, 13, 'paper', at('#title', 'below', 0, 8, 150)),
  text('affiliation', '{attr.affiliation}', SANS, 8, 'mist', at('#author', 'below', 0, 1.6, 150),
    { lineHeight: 1.35 }),
  text('source', '{attr.source}', SANS, 7.4, 'muted', at('page', 'top-left', INNER, BAND + 4,
    MEASURE), { lineHeight: 1.35 }),
] } };
```

Ο τίτλος είναι η μόνη επικεφαλίδα επιπέδου 1· το στιλ της, `essay`, απλώνεται σε όλη τη σελίδα και σχεδιάζει τη ζώνη, το προτιτλικό, τον συγγραφέα, τους φορείς και τη γραμμή πηγής από χαρακτηριστικά της επικεφαλίδας, έτσι η ισπανική έκδοση αλλάζει μόνο λέξεις. Η περίληψη είναι ένα πλαίσιο σε όλο το πλάτος της σελίδας πάνω σε τόνο. Το Box 1, το λυμένο παράδειγμα, πηγαίνει ως κινητό στοιχείο στο κάτω μέρος μιας σελίδας και στις δύο στήλες και στοιχειοθετεί το κείμενό του σε δύο στήλες μέσα στο πλαίσιο. Τα πορίσματα κρατούν τη μορφή του άρθρου με τον τίτλο μέσα στη γραμμή: το `:chip[Corollary 1]{style="corollary"}` δίνει στο καθένα μια μικρή κιναβαρένια ετικέτα πριν από την έντονη διατύπωσή του.

```js
// script.js, γραμμές 130–159
const calloutStyles = [
  { id: 'summary', span: 'page', background: col('tint'), marginTop: pt(0),
    marginBottom: pt(LEAD), padding: { top: mm(4), right: mm(6), bottom: mm(4), left: mm(6) },
    titleStyle: { fontFamily: SANS, fontSize: pt(8), ...caps(8), color: col('accent'),
      gap: mm(1.5) },
    body: { fontSize: pt(9.4), lineHeight: pt(13), firstLineIndent: pt(0) } },
  { id: 'box', span: 'page', placement: 'bottom', columnGap: mm(GUTTER),
    backgroundEnabled: false, border: { enabled: false },
    stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('navy') },
    padding: { top: mm(2.5), right: mm(0), bottom: mm(1), left: mm(0) },
    marginTop: pt(LEAD), marginBottom: pt(LEAD),
    titleStyle: { fontFamily: SANS, fontSize: pt(9), fontWeight: 700, color: col('navy'),
      gap: mm(1.2) },
    body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.2), firstLineIndent: mm(3) } },
  // The journal's first-page note (competing interests, abbreviation) floated to the foot of
  // the first column under a hairline, as PLoS Medicine sets it.
  { id: 'note', placement: 'bottom', backgroundEnabled: false, border: { enabled: false },
    stripe: { enabled: true, side: 'top', width: pt(0.5), color: col('rule') },
    padding: { top: mm(1.6), right: mm(0), bottom: mm(0), left: mm(0) },
    marginTop: pt(LEAD), marginBottom: pt(0),
    body: { fontFamily: SANS, fontSize: pt(7.6), lineHeight: pt(10.4), color: col('muted'),
      boldColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0) } },
];
// :chip[Corollary 1]{style="corollary"}: a label in the sans and the accent, no frame.
const chipStyles = [{ id: 'corollary', fontFamily: SANS, fontSize: em(0.86), bold: true,
  color: col('accent'), backgroundEnabled: false, borderWidth: pt(0), paddingX: em(0),
  gap: em(0.35) }];
const paragraphStyles = [{ id: 'colophon', fontFamily: SANS, fontSize: pt(7.6),
  lineHeight: pt(10.4), color: col('muted'), boldColor: col('ink'), textAlign: 'left',
  firstLineIndent: pt(0), spaceBetween: pt(3) }];
```

Η σημείωση της πρώτης σελίδας του περιοδικού, τα ανταγωνιστικά συμφέροντα και η συντομογραφία, είναι ένα πλαίσιο με στιλ `note` και `placement: 'bottom'`: πηγαίνει στο κάτω μέρος της πρώτης στήλης που έχει χώρο γι' αυτό, κάτω από μια λεπτή γραμμή, και η σελίδα 1 της αγγλικής έκδοσης τελειώνει και τις δύο στήλες στο ίδιο ύψος. Το `headings.balancing.fillShortColumns` αφήνει μια παράγραφο να μακρύνει κατά μία γραμμή, κάτι που κλείνει τις δύο στήλες των αναφορών στο ίδιο ύψος στην τελευταία σελίδα.

## Η πλήρης συνταγή

Ένα αρχείο, συντεθειμένο από τον φάκελο της συνταγής με το δείγμα κειμένου και το κοινό κιτ του Συνταγολογίου ενσωματωμένα· φτιάχνει τη δική του σελίδα. Για να το εκτελέσετε, βάλτε το σε ένα `<script type="module">` σε μια κενή σελίδα, ή επικολλήστε το στο πάνελ JS ενός νέου CodePen (ως module). Εισάγει το postext από το esm.sh, οπότε δεν χρειάζεται εγκατάσταση ούτε build.

- Φάκελος πηγής: https://github.com/drnachio/postext/tree/main/cookbook/bilingual-metascience-essay

### script.js

```js
// ═══ 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
// 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)
// #endregion

// #region title: the essay's first page: a navy band with the title, author and source
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 }),
] } };
// #endregion

// Running heads 13 mm from the trim; the first page has its folio at the foot instead.
const head = (id, content, parity, edge, x, extra) => text(id, content, SANS, 7.5, 'muted',
  at('page', `top-${edge}`, x, 13), { overflow: 'clip', ...caps(7.5, 600), align: edge,
    parity, pages: 'body', ...extra });
const folio = { fontWeight: 800, color: col('accent'), letterSpacing: pt(0.4) };
const RUNNING = ['Ioannidis · PLoS Medicine 2005', t({ en: 'Why most published research '
  + 'findings are false', es: 'Por qué la mayoría de los resultados publicados son falsos' })];
const header = { elements: [
  head('v-folio', '{pageNumber}', 'even', 'left', OUTER, folio),
  head('v-title', RUNNING[0], 'even', 'left', OUTER + 9),
  head('r-title', RUNNING[1], 'odd', 'right', -(OUTER + 9)),
  head('r-folio', '{pageNumber}', 'odd', 'right', -OUTER, folio),
] };
const footer = { elements: [text('drop-folio', '{pageNumber}', SANS, 7.5, 'accent',
  at('page', 'bottom-right', -OUTER, -12), { ...folio, align: 'right', pages: 'opener',
    overflow: 'clip' })] };

const config = () => ({
  ...edition, colorPalette, header, footer,
  // The running heads are the journal's short forms of the paper's name (#849).
  checks: { contentInConfig: { allow: RUNNING } },
  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(BODY), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    referenceBold: false, textAlign: 'justify', firstLineIndent: mm(4),
    indentAfterHeading: false, hyphenation: { enabled: true }, optimalLineBreaking: true,
    avoidWidows: true, avoidOrphans: true, avoidRunts: true },
  math: { marginTop: pt(LEAD / 2), marginBottom: pt(LEAD / 2), keepWithLeadIn: true },
  // fillShortColumns: a paragraph may run a line long so that the references close level.
  headings: { fontFamily: SANS, color: col('navy'), fontWeight: 700,
    balancing: { fillShortColumns: true }, levels: [
    { level: 1, breakBefore: { enabled: true, parity: 'any' } }, // the next page, either side
    { level: 2, fontSize: pt(12), lineHeight: pt(LEAD), marginTop: pt(LEAD),
      marginBottom: pt(LEAD / 2) },
  ] },
  headingStyles: [
    { id: 'essay', numbered: false, span: 'page', advancedDesign: titleBlock },
    { id: 'back', fontSize: pt(8), ...caps(8), color: col('accent'), marginBottom: pt(4) },
  ],
  calloutStyles, chipStyles, paragraphStyles, tableStyle, captionStyle,
});

// #region boxes: the summary across the page, Box 1 under a stripe, run-in corollary labels
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) }];
// #endregion

// ─── 2 · Content ────────────────────────────────────────────────────────────
const markdown = [
  String.raw`---
title: "Why Most Published Research Findings Are False"
author: "John P. A. Ioannidis"
---

# Why Most Published Research Findings Are False {style="essay" kicker="Essay · Research methods" author="John P. A. Ioannidis" affiliation="University of Ioannina School of Medicine, Ioannina, Greece\nTufts University School of Medicine, Boston, Massachusetts, United States" source="Originally published in PLoS Medicine 2(8): e124, 30 August 2005 · doi:10.1371/journal.pmed.0020124 · © 2005 John P. A. Ioannidis, Creative Commons Attribution License"}

:::callout{type="summary" title="Summary"}
There is increasing concern that most current published research findings are false. The probability that a research claim is true may depend on study power and bias, the number of other studies on the same question, and, importantly, the ratio of true to no relationships among the relationships probed in each scientific field. In this framework, a research finding is less likely to be true when the studies conducted in a field are smaller; when effect sizes are smaller; when there is a greater number and lesser preselection of tested relationships; where there is greater flexibility in designs, definitions, outcomes, and analytical modes; when there is greater financial and other interest and prejudice; and when more teams are involved in a scientific field in chase of statistical significance. Simulations show that for most study designs and settings, it is more likely for a research claim to be false than true. Moreover, for many current scientific fields, claimed research findings may often be simply accurate measures of the prevailing bias. In this essay, I discuss the implications of these problems for the conduct and interpretation of research.
:::

Published research findings are sometimes refuted by subsequent evidence, with ensuing confusion and disappointment. Refutation and controversy is seen across the range of research designs, from clinical trials and traditional epidemiological studies [@ioannidis2001a; @lawlor2004; @vandenbroucke2004] to the most modern molecular research [@michiels2005; @ioannidis2001b]. There is increasing concern that in modern research, false findings may be the majority or even the vast majority of published research claims [@colhoun2003; @ioannidis2003; @ioannidis2005a]. However, this should not be surprising. It can be proven that most claimed research findings are false. Here I will examine the key factors that influence this problem and some corollaries thereof.

:::callout{type="note"}
**Competing interests.** The author has declared that no competing interests exist. **Abbreviation.** PPV, positive predictive value.
:::


## Modeling the Framework for False Positive Findings

Several methodologists have pointed out [@sterne2001; @wacholder2004; @risch2000] that the high rate of nonreplication (lack of confirmation) of research discoveries is a consequence of the convenient, yet ill-founded strategy of claiming conclusive research findings solely on the basis of a single study assessed by formal statistical significance, typically for a *p*-value less than 0.05.

As has been shown previously, the probability that a research finding is indeed true depends on the prior probability of it being true (before doing the study), the statistical power of the study, and the level of statistical significance [@wacholder2004; @risch2000]. Consider a 2 × 2 table in which research findings are compared against the gold standard of true relationships in a scientific field. In a research field both true and false hypotheses can be made about the presence of relationships. Let $R$ be the ratio of the number of “true relationships” to “no relationships” among those tested in the field. $R$ is characteristic of the field and can vary a lot depending on whether the field targets highly likely relationships or searches for only one or a few true relationships among thousands and millions of hypotheses that may be postulated. Let us also consider, for computational simplicity, circumscribed fields where either there is only one true relationship (among many that can be hypothesized) or the power is similar to find any of the several existing true relationships. The pre-study probability of a relationship being true is $R/(R+1)$. The probability of a study finding a true relationship reflects the power $1-\beta$ (one minus the Type II error rate). The probability of claiming a relationship when none truly exists reflects the Type I error rate, $\alpha$. Assuming that $c$ relationships are being probed in the field, the expected values of the 2 × 2 table are given in :ref{id="tbl-truth"}. After a research finding has been claimed based on achieving formal statistical significance, the post-study probability that it is true is the positive predictive value, PPV. The PPV is also the complementary probability of what Wacholder et al. have called the false positive report probability [@wacholder2004]. According to the 2 × 2 table, one gets
$$\mathrm{PPV} = \frac{(1-\beta)R}{R-\beta R+\alpha}. \tag{1}$$
A research finding is thus more likely true than false if $(1-\beta)R > \alpha$. Since usually the vast majority of investigators depend on $\alpha = 0.05$, this means that a research finding is more likely true than false if $(1-\beta)R > 0.05$.

What is less well appreciated is that bias and the extent of repeated independent testing by different teams of investigators around the globe may further distort this picture and may lead to even smaller probabilities of the research findings being indeed true. We will try to model these two factors in the context of similar 2 × 2 tables.

## Bias

First, let us define bias as the combination of various design, data, analysis, and presentation factors that tend to produce research findings when they should not be produced. Let $u$ be the proportion of probed analyses that would not have been “research findings,” but nevertheless end up presented and reported as such, because of bias. Bias should not be confused with chance variability that causes some findings to be false by chance even though the study design, data, analysis, and presentation are perfect. Bias can entail manipulation in the analysis or reporting of findings. Selective or distorted reporting is a typical form of such bias. We may assume that $u$ does not depend on whether a true relationship exists or not. This is not an unreasonable assumption, since typically it is impossible to know which relationships are indeed true. In the presence of bias (:ref{id="tbl-bias"}), one gets
$$\mathrm{PPV} = \frac{[1-\beta]R+u\beta R}{R+\alpha-\beta R+u-u\alpha+u\beta R}, \tag{2}$$
and PPV decreases with increasing $u$, unless $1-\beta \le \alpha$, i.e., $1-\beta \le 0.05$ for most situations. Thus, with increasing bias, the chances that a research finding is true diminish considerably. This is shown for different levels of power and for different pre-study odds in :ref{id="fig-bias"}.

## Testing by Several Independent Teams

Several independent teams may be addressing the same sets of research questions. As research efforts are globalized, it is practically the rule that several research teams, often dozens of them, may probe the same or similar questions. The probability that at least one study, among several done on the same question, claims a statistically significant research finding is easy to estimate. For $n$ independent studies of equal power, the 2 × 2 table is shown in :ref{id="tbl-teams"}:
$$\mathrm{PPV} = \frac{R(1-\beta^n)}{R+1-[1-\alpha]^n-R\beta^n} \tag{3}$$
(not considering bias). With increasing number of independent studies, PPV tends to decrease, unless $1-\beta < \alpha$, i.e., typically $1-\beta < 0.05$. This is shown for different levels of power and for different pre-study odds in :ref{id="fig-teams"}. For $n$ studies of different power, the term $\beta^n$ is replaced by the product of the terms $\beta_i$ for $i = 1$ to $n$, but inferences are similar.
`, // title, summary, the model, bias, several teams
  String.raw`## Corollaries

A practical example is shown in Box 1. Based on the above considerations, one may deduce several interesting corollaries about the probability that a research finding is indeed true.

:::callout{type="box" title="Box 1. An Example: Science at Low Pre-Study Odds"}
:::columns{count=2}
Let us assume that a team of investigators performs a whole genome association study to test whether any of 100,000 gene polymorphisms are associated with susceptibility to schizophrenia. Based on what we know about the extent of heritability of the disease, it is reasonable to expect that probably around ten gene polymorphisms among those tested would be truly associated with schizophrenia, with relatively similar odds ratios around 1.3 for the ten or so polymorphisms and with a fairly similar power to identify any of them. Then $R = 10/100{,}000 = 10^{-4}$, and the pre-study probability for any polymorphism to be associated with schizophrenia is also $R/(R+1) = 10^{-4}$. Let us also suppose that the study has 60% power to find an association with an odds ratio of 1.3 at $\alpha = 0.05$. Then it can be estimated that if a statistically significant association is found with the *p*-value barely crossing the 0.05 threshold, the post-study probability that this is true increases about 12-fold compared with the pre-study probability, but it is still only $12 \times 10^{-4}$.

Now let us suppose that the investigators manipulate their design, analyses, and reporting so as to make more relationships cross the *p* = 0.05 threshold even though this would not have been crossed with a perfectly adhered to design and analysis and with perfect comprehensive reporting of the results, strictly according to the original study plan. In the presence of bias with $u = 0.10$, the post-study probability that a research finding is true is only $4.4 \times 10^{-4}$. Furthermore, even in the absence of any bias, when ten independent research teams perform similar experiments around the world, if one of them finds a formally statistically significant association, the probability that the research finding is true is only $1.5 \times 10^{-4}$, hardly any higher than the probability we had before any of this extensive research was undertaken!
:::
:::

:chip[Corollary 1]{style="corollary"} **The smaller the studies conducted in a scientific field, the less likely the research findings are to be true.** Small sample size means smaller power and, for all functions above, the PPV for a true research finding decreases as power decreases towards $1-\beta = 0.05$. Thus, other factors being equal, research findings are more likely true in scientific fields that undertake large studies, such as randomized controlled trials in cardiology (several thousand subjects randomized) [@yusuf1984] than in scientific fields with small studies, such as most research of molecular predictors (sample sizes 100-fold smaller) [@altman2000].

:chip[Corollary 2]{style="corollary"} **The smaller the effect sizes in a scientific field, the less likely the research findings are to be true.** Power is also related to the effect size. Thus research findings are more likely true in scientific fields with large effects, such as the impact of smoking on cancer or cardiovascular disease (relative risks 3–20), than in scientific fields where postulated effects are small, such as genetic risk factors for multigenetic diseases (relative risks 1.1–1.5) [@ioannidis2003]. Modern epidemiology is increasingly obliged to target smaller effect sizes [@taubes1995]. Consequently, the proportion of true research findings is expected to decrease.

:chip[Corollary 3]{style="corollary"} **The greater the number and the lesser the selection of tested relationships in a scientific field, the less likely the research findings are to be true.** As shown above, the post-study probability that a finding is true (PPV) depends a lot on the pre-study odds ($R$). Thus, research findings are more likely true in confirmatory designs, such as large phase III randomized controlled trials, or meta-analyses thereof, than in hypothesis-generating experiments. Fields considered highly informative and creative given the wealth of the assembled and tested information, such as microarrays and other high-throughput discovery-oriented research [@michiels2005; @ioannidis2005a; @golub1999], should have extremely low PPV.

:chip[Corollary 4]{style="corollary"} **The greater the flexibility in designs, definitions, outcomes, and analytical modes in a scientific field, the less likely the research findings are to be true.** Flexibility increases the potential for transforming what would be “negative” results into “positive” results, i.e., bias, $u$. For several research designs, e.g., randomized controlled trials [@moher2001; @ioannidis2004; @ich1999] or meta-analyses [@moher1999; @stroup2000], there have been efforts to standardize their conduct and reporting. Adherence to common standards is likely to increase the proportion of true findings. Regardless, even in the most stringent research designs, bias seems to be a major problem. For example, there is strong evidence that selective outcome reporting, with manipulation of the outcomes and analyses reported, is a common problem even for randomized trials [@chan2004]. Simply abolishing selective publication would not make this problem go away.

:chip[Corollary 5]{style="corollary"} **The greater the financial and other interests and prejudices in a scientific field, the less likely the research findings are to be true.** Conflicts of interest and prejudice may increase bias, $u$. Conflicts of interest are very common in biomedical research [@krimsky1998], and typically they are inadequately and sparsely reported [@krimsky1998; @papanikolaou2001]. Prejudice may not necessarily have financial roots. Scientists in a given field may be prejudiced purely because of their belief in a scientific theory or commitment to their own findings. Prestigious investigators may suppress via the peer review process the appearance and dissemination of findings that refute their findings, thus condemning their field to perpetuate false dogma. Empirical evidence on expert opinion shows that it is extremely unreliable [@antman1992].

:chip[Corollary 6]{style="corollary"} **The hotter a scientific field (with more scientific teams involved), the less likely the research findings are to be true.** This seemingly paradoxical corollary follows because, as stated above, the PPV of isolated findings decreases when many teams of investigators are involved in the same field. This may explain why we occasionally see major excitement followed rapidly by severe disappointments in fields that draw wide attention. The term Proteus phenomenon has been coined to describe this phenomenon of rapidly alternating extreme research claims and extremely opposite refutations [@ioannidis2005b]. Empirical evidence suggests that this sequence of extreme opposites is very common in molecular genetics [@ioannidis2005b].
`, // Box 1 and the six corollaries
  String.raw`## Most Research Findings Are False for Most Research Designs and for Most Fields

In the described framework, a PPV exceeding 50% is quite difficult to get. :ref{id="tbl-ppv"} provides the results of simulations using the formulas developed for the influence of power, ratio of true to non-true relationships, and bias, for various types of situations that may be characteristic of specific study designs and settings. A finding from a well-conducted, adequately powered randomized controlled trial starting with a 50% pre-study chance that the intervention is effective is eventually true about 85% of the time. A fairly similar performance is expected of a confirmatory meta-analysis of good-quality randomized trials: potential bias probably increases, but power and pre-test chances are higher compared to a single randomized trial. Conversely, a meta-analytic finding from inconclusive studies where pooling is used to “correct” the low power of single studies, is probably false if $R \le 1{:}3$. Research findings from underpowered, early-phase clinical trials would be true about one in four times, or even less frequently if bias is present. Epidemiological studies of an exploratory nature perform even worse, especially when underpowered, but even well-powered epidemiological studies may have only a one in five chance being true, if $R = 1{:}10$. Finally, in discovery-oriented research with massive testing, where tested relationships exceed true ones 1,000-fold (e.g., 30,000 genes tested, of which 30 may be the true culprits) [@ntzani2003; @ransohoff2004], PPV for each claimed relationship is extremely low, even with considerable standardization of laboratory and statistical methods, outcomes, and reporting thereof to minimize bias.

## Claimed Research Findings May Often Be Simply Accurate Measures of the Prevailing Bias

As shown, the majority of modern biomedical research is operating in areas with very low pre- and post-study probability for true findings. Let us suppose that in a research field there are no true findings at all to be discovered. In such a “null field,” one would ideally expect all observed effect sizes to vary by chance around the null in the absence of bias. The extent that observed findings deviate from what is expected by chance alone would be simply a pure measure of the prevailing bias.

For example, let us suppose that no nutrients or dietary patterns are actually important determinants for the risk of developing a specific tumor. Let us also suppose that the scientific literature has examined 60 nutrients and claims all of them to be related to the risk of developing this tumor with relative risks in the range of 1.2 to 1.4 for the comparison of the upper to lower intake tertiles. Then the claimed effect sizes are simply measuring nothing else but the net bias that has been involved in the generation of this scientific literature. Claimed effect sizes are in fact the most accurate estimates of the net bias. It even follows that between “null fields,” the fields that claim stronger effects (often with accompanying claims of medical or public health importance) are simply those that have sustained the worst biases.

For fields with very low PPV, the few true relationships would not distort this overall picture much. Even if a few relationships are true, the shape of the distribution of the observed effects would still yield a clear measure of the biases involved in the field. This concept totally reverses the way we view scientific results. Traditionally, investigators have viewed large and highly significant effects with excitement, as signs of important discoveries. Too large and too highly significant effects may actually be more likely to be signs of large bias in most fields of modern research. They should lead investigators to careful critical thinking about what might have gone wrong with their data, analyses, and results.

## How Can We Improve the Situation?

Is it unavoidable that most research findings are false, or can we improve the situation? A major problem is that it is impossible to know with 100% certainty what the truth is in any research question. In this regard, the pure “gold” standard is unattainable. However, there are several approaches to improve the post-study probability.

Better powered evidence, e.g., large studies or low-bias meta-analyses, may help, as it comes closer to the unknown “gold” standard. However, large studies may still have biases and these should be acknowledged and avoided. Moreover, one should be cautious that extremely large studies may be more likely to find a formally statistical significant difference for a trivial effect that is not really meaningfully different from the null [@lindley1957; @bartlett1957; @senn2001].

Second, most research questions are addressed by many teams, and it is misleading to emphasize the statistically significant findings of any single team. What matters is the totality of the evidence. Diminishing bias through enhanced research standards and curtailing of prejudices may also help. However, this may require a change in scientific mentality that might be difficult to achieve. In some research designs, efforts may also be more successful with upfront registration of studies, e.g., randomized trials [@deangelis2004]. Registration would pose a challenge for hypothesis-generating research. Some kind of registration or networking of data collections or investigators within fields may be more feasible than registration of each and every hypothesis-generating experiment. Regardless, even if we do not see a great deal of progress with registration of studies in other fields, the principles of developing and adhering to a protocol could be more widely borrowed from randomized controlled trials.

Finally, instead of chasing statistical significance, we should improve our understanding of the range of $R$ values—the pre-study odds—where research efforts operate [@wacholder2004]. Before running an experiment, investigators should consider what they believe the chances are that they are testing a true rather than a non-true relationship. Speculated high $R$ values may sometimes then be ascertained. As described above, whenever ethically acceptable, large studies with minimal bias should be performed on research findings that are considered relatively established, to see how often they are indeed confirmed. I suspect several established “classics” will fail the test [@ioannidis2005c].

Nevertheless, most new discoveries will continue to stem from hypothesis-generating research with low or very low pre-study odds. We should then acknowledge that statistical significance testing in the report of a single study gives only a partial picture, without knowing how much testing has been done outside the report and in the relevant field at large. Despite a large statistical literature for multiple testing corrections [@hsueh2003], usually it is impossible to decipher how much data dredging by the reporting authors or other research teams has preceded a reported research finding. Even if determining this were feasible, this would not inform us about the pre-study odds. Thus, it is unavoidable that one should make approximate assumptions on how many relationships are expected to be true among those probed across the relevant research fields and research designs. Even though these assumptions would be considerably subjective, they would still be very useful in interpreting research claims and putting them in context.

## Article information {style="back"}

:::paragraphs{style="colophon"}
**This edition.** Abridged from J. P. A. Ioannidis, “Why Most Published Research Findings Are False”, *PLoS Medicine* 2(8): e124 (2005), doi:10.1371/journal.pmed.0020124, under the Creative Commons Attribution License. Some sentences and paragraphs are left out, the formulas are numbered, the tables and figures are redrawn and one typing slip is corrected. Set in Gelasio and Sofia Sans Semi Condensed (SIL OFL); formulas by MathJax.
:::

## References {style="back"}

:::bibliography{title=""}
`, // the last three sections and the back matter
  String.raw`:::references{format=bibtex}
@article{ioannidis2001a, author = {Ioannidis, J. P. and Haidich, A. B. and Lau, J.},
  title = {Any casualties in the clash of randomised and observational evidence?},
  journal = {BMJ}, year = 2001, volume = 322, pages = {879--880}}
@article{lawlor2004, author = {Lawlor, D. A. and Davey Smith, G. and Kundu, D. and Bruckdorfer, K. R. and Ebrahim, S.},
  title = {Those confounded vitamins: what can we learn from the differences between observational versus randomised trial evidence?},
  journal = {Lancet}, year = 2004, volume = 363, pages = {1724--1727}}
@article{vandenbroucke2004, author = {Vandenbroucke, J. P.},
  title = {When are observational studies as credible as randomised trials?},
  journal = {Lancet}, year = 2004, volume = 363, pages = {1728--1731}}
@article{michiels2005, author = {Michiels, S. and Koscielny, S. and Hill, C.},
  title = {Prediction of cancer outcome with microarrays: a multiple random validation strategy},
  journal = {Lancet}, year = 2005, volume = 365, pages = {488--492}}
@article{ioannidis2001b, author = {Ioannidis, J. P. A. and Ntzani, E. E. and Trikalinos, T. A. and Contopoulos-Ioannidis, D. G.},
  title = {Replication validity of genetic association studies},
  journal = {Nat Genet}, year = 2001, volume = 29, pages = {306--309}}
@article{colhoun2003, author = {Colhoun, H. M. and McKeigue, P. M. and Davey Smith, G.},
  title = {Problems of reporting genetic associations with complex outcomes},
  journal = {Lancet}, year = 2003, volume = 361, pages = {865--872}}
@article{ioannidis2003, author = {Ioannidis, J. P.},
  title = {Genetic associations: false or true?},
  journal = {Trends Mol Med}, year = 2003, volume = 9, pages = {135--138}}
@article{ioannidis2005a, author = {Ioannidis, J. P. A.},
  title = {Microarrays and molecular research: noise discovery?},
  journal = {Lancet}, year = 2005, volume = 365, pages = {454--455}}
@article{sterne2001, author = {Sterne, J. A. and Davey Smith, G.},
  title = {Sifting the evidence---what's wrong with significance tests?},
  journal = {BMJ}, year = 2001, volume = 322, pages = {226--231}}
@article{wacholder2004, author = {Wacholder, S. and Chanock, S. and Garcia-Closas, M. and El Ghormli, L. and Rothman, N.},
  title = {Assessing the probability that a positive report is false: an approach for molecular epidemiology studies},
  journal = {J Natl Cancer Inst}, year = 2004, volume = 96, pages = {434--442}}
@article{risch2000, author = {Risch, N. J.},
  title = {Searching for genetic determinants in the new millennium},
  journal = {Nature}, year = 2000, volume = 405, pages = {847--856}}
@article{yusuf1984, author = {Yusuf, S. and Collins, R. and Peto, R.},
  title = {Why do we need some large, simple randomized trials?},
  journal = {Stat Med}, year = 1984, volume = 3, pages = {409--422}}
@article{altman2000, author = {Altman, D. G. and Royston, P.},
  title = {What do we mean by validating a prognostic model?},
  journal = {Stat Med}, year = 2000, volume = 19, pages = {453--473}}
@article{taubes1995, author = {Taubes, G.},
  title = {Epidemiology faces its limits},
  journal = {Science}, year = 1995, volume = 269, pages = {164--169}}
@article{golub1999, author = {Golub, T. R. and Slonim, D. K. and Tamayo, P. and Huard, C. and Gaasenbeek, M. and others},
  title = {Molecular classification of cancer: class discovery and class prediction by gene expression monitoring},
  journal = {Science}, year = 1999, volume = 286, pages = {531--537}}
@article{moher2001, author = {Moher, D. and Schulz, K. F. and Altman, D. G.},
  title = {The {CONSORT} statement: revised recommendations for improving the quality of reports of parallel-group randomised trials},
  journal = {Lancet}, year = 2001, volume = 357, pages = {1191--1194}}
@article{ioannidis2004, author = {Ioannidis, J. P. and Evans, S. J. and Gøtzsche, P. C. and O'Neill, R. T. and Altman, D. G. and others},
  title = {Better reporting of harms in randomized trials: an extension of the {CONSORT} statement},
  journal = {Ann Intern Med}, year = 2004, volume = 141, pages = {781--788}}
@article{ich1999, author = {{International Conference on Harmonisation E9 Expert Working Group}},
  title = {{{ICH}} {{Harmonised Tripartite Guideline}}. Statistical principles for clinical trials},
  journal = {Stat Med}, year = 1999, volume = 18, pages = {1905--1942}}
@article{moher1999, author = {Moher, D. and Cook, D. J. and Eastwood, S. and Olkin, I. and Rennie, D. and others},
  title = {Improving the quality of reports of meta-analyses of randomised controlled trials: the {QUOROM} statement. {Quality of Reporting of Meta-analyses}},
  journal = {Lancet}, year = 1999, volume = 354, pages = {1896--1900}}
@article{stroup2000, author = {Stroup, D. F. and Berlin, J. A. and Morton, S. C. and Olkin, I. and Williamson, G. D. and others},
  title = {Meta-analysis of observational studies in epidemiology: a proposal for reporting. {Meta-analysis Of Observational Studies in Epidemiology} ({MOOSE}) group},
  journal = {JAMA}, year = 2000, volume = 283, pages = {2008--2012}}
@article{chan2004, author = {Chan, A. W. and Hróbjartsson, A. and Haahr, M. T. and Gøtzsche, P. C. and Altman, D. G.},
  title = {Empirical evidence for selective reporting of outcomes in randomized trials: comparison of protocols to published articles},
  journal = {JAMA}, year = 2004, volume = 291, pages = {2457--2465}}
@article{krimsky1998, author = {Krimsky, S. and Rothenberg, L. S. and Stott, P. and Kyle, G.},
  title = {Scientific journals and their authors' financial interests: a pilot study},
  journal = {Psychother Psychosom}, year = 1998, volume = 67, pages = {194--201}}
@article{papanikolaou2001, author = {Papanikolaou, G. N. and Baltogianni, M. S. and Contopoulos-Ioannidis, D. G. and Haidich, A. B. and Giannakakis, I. A. and others},
  title = {Reporting of conflicts of interest in guidelines of preventive and therapeutic interventions},
  journal = {BMC Med Res Methodol}, year = 2001, volume = 1, pages = {3}}
@article{antman1992, author = {Antman, E. M. and Lau, J. and Kupelnick, B. and Mosteller, F. and Chalmers, T. C.},
  title = {A comparison of results of meta-analyses of randomized control trials and recommendations of clinical experts. {Treatments for myocardial infarction}},
  journal = {JAMA}, year = 1992, volume = 268, pages = {240--248}}
@article{ioannidis2005b, author = {Ioannidis, J. P. and Trikalinos, T. A.},
  title = {Early extreme contradictory estimates may appear in published research: the {Proteus} phenomenon in molecular genetics research and randomized trials},
  journal = {J Clin Epidemiol}, year = 2005, volume = 58, pages = {543--549}}
@article{ntzani2003, author = {Ntzani, E. E. and Ioannidis, J. P.},
  title = {Predictive ability of {DNA} microarrays for cancer outcomes and correlates: an empirical assessment},
  journal = {Lancet}, year = 2003, volume = 362, pages = {1439--1444}}
@article{ransohoff2004, author = {Ransohoff, D. F.},
  title = {Rules of evidence for cancer molecular-marker discovery and validation},
  journal = {Nat Rev Cancer}, year = 2004, volume = 4, pages = {309--314}}
@article{lindley1957, author = {Lindley, D. V.}, title = {A statistical paradox},
  journal = {Biometrika}, year = 1957, volume = 44, pages = {187--192}}
@article{bartlett1957, author = {Bartlett, M. S.}, title = {A comment on {D. V. Lindley's} statistical paradox},
  journal = {Biometrika}, year = 1957, volume = 44, pages = {533--534}}
@article{senn2001, author = {Senn, S. J.},
  title = {Two cheers for {P}-values?},
  journal = {J Epidemiol Biostat}, year = 2001, volume = 6, pages = {193--204}}
@article{deangelis2004, author = {De Angelis, C. and Drazen, J. M. and Frizelle, F. A. and Haug, C. and Hoey, J. and others},
  title = {Clinical trial registration: a statement from the {International Committee of Medical Journal Editors}},
  journal = {N Engl J Med}, year = 2004, volume = 351, pages = {1250--1251}}
@article{ioannidis2005c, author = {Ioannidis, J. P. A.},
  title = {Contradicted and initially stronger effects in highly cited clinical research},
  journal = {JAMA}, year = 2005, volume = 294, pages = {218--228}}
@article{hsueh2003, author = {Hsueh, H. M. and Chen, J. J. and Kodell, R. L.},
  title = {Comparison of methods for estimating the number of true null hypotheses in multiplicity testing},
  journal = {J Biopharm Stat}, year = 2003, volume = 13, pages = {675--689}}
:::
`, // the references as BibTeX, shared by both editions
].join('\n\n');
// Captions, notes and the tables as tab-separated text with TeX in the cells, one block each.
const blocks = String.raw`id: tbl-truth
caption: Research Findings and True Relationships
Research finding	True relationship		
	Yes	No	Total
Yes	$c(1-\beta)R/(R+1)$	$c\alpha/(R+1)$	$c(R+\alpha-\beta R)/(R+1)$
No	$c\beta R/(R+1)$	$c(1-\alpha)/(R+1)$	$c(1-\alpha+\beta R)/(R+1)$
Total	$cR/(R+1)$	$c/(R+1)$	$c$

id: tbl-bias
caption: Research Findings and True Relationships in the Presence of Bias
Research finding	True relationship		
	Yes	No	Total
Yes	$(c[1-\beta]R+uc\beta R)/(R+1)$	$c\alpha+uc(1-\alpha)/(R+1)$	$c(R+\alpha-\beta R+u-u\alpha+u\beta R)/(R+1)$
No	$(1-u)c\beta R/(R+1)$	$(1-u)c(1-\alpha)/(R+1)$	$c(1-u)(1-\alpha+\beta R)/(R+1)$
Total	$cR/(R+1)$	$c/(R+1)$	$c$

id: tbl-teams
caption: Research Findings and True Relationships in the Presence of Multiple Studies
Research finding	True relationship		
	Yes	No	Total
Yes	$cR(1-\beta^n)/(R+1)$	$c(1-[1-\alpha]^n)/(R+1)$	$c(R+1-[1-\alpha]^n-R\beta^n)/(R+1)$
No	$cR\beta^n/(R+1)$	$c(1-\alpha)^n/(R+1)$	$c([1-\alpha]^n+R\beta^n)/(R+1)$
Total	$cR/(R+1)$	$c/(R+1)$	$c$

id: tbl-ppv
caption: PPV of Research Findings for Various Combinations of Power ($1-\beta$), Ratio of True to Not-True Relationships ($R$), and Bias ($u$)
note: The estimated PPVs (positive predictive values) are derived assuming $\alpha = 0.05$ for a single study; here they are computed from Eq. (2).\\RCT, randomized controlled trial.
$1-\beta$	$R$	$u$	Practical example	PPV
0.80	1:1	0.10	Adequately powered RCT with little bias and 1:1 pre-study odds	
0.95	2:1	0.30	Confirmatory meta-analysis of good-quality RCTs	
0.80	1:3	0.40	Meta-analysis of small inconclusive studies	
0.20	1:5	0.20	Underpowered, but well-performed phase I/II RCT	
0.20	1:5	0.80	Underpowered, poorly performed phase I/II RCT	
0.80	1:10	0.30	Adequately powered exploratory epidemiological study	
0.20	1:10	0.30	Underpowered exploratory epidemiological study	
0.20	1:1,000	0.80	Discovery-oriented exploratory research with massive testing	
0.20	1:1,000	0.20	As in previous example, but with more limited bias (more standardized)

id: fig-bias
caption: PPV (Probability That a Research Finding Is True) as a Function of the Pre-Study Odds for Various Levels of Bias, $u$
note: Panels correspond to power of 0.80, 0.50, and 0.20. Drawn in code from Eq. (2) for the values of $u$ in the 2005 legend, with no bias ($u = 0$) dashed; the curves printed in 2005 match $u = 0$, 0.05, 0.20 and 0.80.
alt: Three panels of rising curves: PPV grows with the pre-study odds and falls as bias grows.

id: fig-teams
caption: PPV (Probability That a Research Finding Is True) as a Function of the Pre-Study Odds for Various Numbers of Conducted Studies, $n$
note: Panels correspond to power of 0.80, 0.50, and 0.20. Drawn in code from Eq. (3).
alt: Three panels of rising curves: PPV falls as more teams test the same question.
`;

// #region tables: TSV in, a merged header, and the $…$ cells set as formulas by the engine
// 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');
// #endregion

// #region resources: each block of the slot is a table or a figure, placed where it is cited
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') } };
// #endregion

// #region art: Figures 1 and 2 drawn from Eqs. (2) and (3), the band's curves from Eq. (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>`;
// #endregion

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { // every face the pages paint, loaded before the first build
  Gelasio: ['400', '400i', '600', '700', '700i'],
  'Sofia Sans Semi Condensed': ['400', '400i', '600', '700', '700i', '800'],
};

// ─── 4 · Build & show ───────────────────────────────────────────────────────
await prepareFonts(markdown + blocks, config(), kitFonts(FONTS));
await loadSvg('fig-bias.svg', panels(ppv, [0.05, 0.2, 0.5, 0.8], 'u', 2,
  (power, R) => ppv(power, R, 0)));
await loadSvg('fig-teams.svg', panels(teams, [1, 5, 10, 50], 'n', 0));
await loadSvg('band-art.svg', bandArt());
const doc = await buildDocumentWithFonts({ markdown, resources }, config(), kitFonts(FONTS));
showPages(doc, { title: t({ en: 'A metascience essay in English and Spanish',
  es: 'Un ensayo de metaciencia en inglés y en español' }) });
offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider, resourceBytes: imageBytes }),
  `${RECIPE}.pdf`); // text in the Fontsource faces; formulas and figures as vector paths

// ─── 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 v3 ── the same in every recipe · postext.dev/cookbook
// Postext loads the faces a config asks for before layout and asks the kit
// for Fontsource's files, the ones the PDF embeds too.

/** buildDocumentWithFonts' options: the resolver, and FONTS' faces loaded
 *  with the config's. FONTS = { 'Family Name': ['400', '400i', '700'] }. */
function kitFonts(FONTS = {}) {
  const faces = Object.entries(FONTS).flatMap(([family, specs]) => specs.map((spec) =>
    ({ family, weight: parseInt(spec, 10), style: spec.endsWith('i') ? 'italic' : 'normal' })));
  return { resolve: fontsourceResolver, faces };
}

/** A face's files with their ranges: latin, then latin-ext and greek when
 *  `text` needs them (kitSubsetsFor). Null for a face Fontsource lacks. */
async function fontsourceResolver(family, weight, style, { text = '' } = {}) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  if (meta && !(await fontsourceWeights(family, style)).includes(weight)) return null;
  kitStatus('Loading fonts…');
  const at = await fontsourceAt(id);
  return ['latin', ...kitSubsetsFor(text, meta)].map((subset) => ({
    source: `${at}files/${id}-${subset}-${weight}-${style}.woff2`,
    unicodeRange: kitRanges()[subset],
  }));
}

/** Each file's unicode-range (a function: the kit runs after the pen's code). */
function kitRanges() {
  return {
    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',
    greek: 'U+0370-03FF',
  };
}

/** For the cjk, arabic and comics blocks: loads `faces` (as FONTS) for the
 *  sample `text`; `optional` skips a face Fontsource lacks. Files are added in
 *  the order asked, the last winning a shared character. Resolves to the count. */
async function loadFonts(faces, text = '', { optional = false } = {}) {
  kitStatus('Loading fonts…');
  const ranges = kitRanges();
  const jobs = [];
  for (const [family, specs] of Object.entries(faces)) {
    const id = fontsourceId(family);
    const todo = [...new Set(specs)].map((spec) => [parseInt(spec, 10), spec.endsWith('i') ? 'italic' : 'normal'])
      .filter(([weight, style]) => !hasFace(family, weight, style)); // before any await
    const at = fontsourceAt(id);
    const meta = optional || /[^\0-ÿ]/u.test(text) ? await fontsourceMeta(family) : null;
    const subsets = ['latin', ...kitSubsetsFor(text, meta)];
    for (const [weight, style] of todo) {
      if (optional && !(meta && (await fontsourceWeights(family, style)).includes(weight))) continue;
      for (const subset of subsets) {
        const url = `${await at}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().catch(() => {
          if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`);
        }));
      }
    }
  }
  const ready = await Promise.all(jobs).catch((error) => { kitFail(error); throw error; });
  return ready.filter((face) => face && document.fonts.add(face)).length;
}

/** A loaded FontFace covers this face (fonts.check() says yes to any family). */
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;
}

/** The files beyond latin `text` needs that `meta`'s family ships. */
function kitSubsetsFor(text, meta) {
  return [[/[Ā-˿ᴀ-ᶿḀ-ỿ†ℓⱠ-Ɀ꜠-ꟿ]/u, 'latin-ext'], [/[Ͱ-Ͽ]/u, 'greek']]
    .filter(([re, x]) => re.test(text) && meta?.subsets?.includes(x)).map(([, x]) => x);
}

/** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */
function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); }

/** A package's folder at the one version @5 names now (#766). */
function fontsourceAt(id, u = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@`) {
  return (fontsourceAt.c ??= {})[id] ??= fetch(u + '5/package.json').then((r) => r.json())
    .then((p) => p.version || 5, () => 5).then((v) => `${u}${v}/`);
}

/** The family's Fontsource metadata (weights, styles, subsets), or null. */
function fontsourceMeta(family, id = fontsourceId(family)) {
  return (fontsourceMeta.c ??= {})[id] ??= fetch(`https://api.fontsource.org/v1/fonts/${id}`)
    .then((res) => (res.ok ? res.json() : null), () => null);
}

/** The weights the package ships in `style`: the API pairs none (no Libre
 *  Caslon 700 italic file), so italics are read from latin-italic.css. */
function fontsourceWeights(family, style, id = fontsourceId(family)) {
  return (fontsourceWeights.c ??= {})[id + style] ??= fontsourceMeta(family).then(async (m) => {
    if (!m?.styles.includes(style)) return m ? [] : [400, 700];
    const css = style === 'italic' ? await fetch(`${await fontsourceAt(id)}latin-italic.css`).then((r) => (r.ok ? r.text() : ''), () => '') : '';
    const w = [...css.matchAll(/weight: (\d+)/g)].map((x) => +x[1]);
    return w.length ? w : m.weights;
  });
}

// ─── Kit · viewer v2 ── the same in every recipe · postext.dev/cookbook
/** The pages as spreads on a dark desk, page 1 alone, then verso | recto,
 *  each painted when it scrolls near. Other options go to renderPageToCanvas. */
function showPages(docs, { title, width = 460, ...render } = {}) {
  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, { ...render, 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 v3 ── the same in every recipe that exports a PDF
/** The Fontsource files the screen used, as TrueType, with their range and
 *  place: the nearest weight the family ships in that style, upright with no italic;
 *  latin, then what its letters need (kitSubsetsFor). */
async function fontsourceProvider(family, weight, style, request) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  const s = style === 'italic' && meta && !meta.styles.includes('italic') ? 'normal' : style;
  const shipped = meta ? await fontsourceWeights(family, s) : [];
  const weights = shipped.length ? shipped : [400, 700];
  const w = weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a));
  const text = String.fromCodePoint(...(request?.codePoints ?? []));
  const files = await Promise.all(['latin', ...kitSubsetsFor(text, meta)].map(async (subset, order) => {
    const res = await fetch(`${await fontsourceAt(id)}files/${id}-${subset}-${w}-${s}.woff2`);
    if (!res.ok) throw new Error(`Fontsource has no ${family} ${w} ${s} ${subset}`);
    return Object.assign(await decompressWoff2(new Uint8Array(await res.arrayBuffer())),
      { unicodeRange: kitRanges()[subset], order });
  }));
  return files.length === 1 ? files[0] : files;
}

/** A "Build the PDF" button; then "Open the PDF" (a new tab: CodePen's frame
 *  shows no 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 v3 ── 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 as a vector image, its fonts inside (inlineSvgFonts, ≥ 1.25).
 *  `options` go to registerResourceImage: { singleInk: true } tints it on the canvas. */
async function loadSvg(fileId, svg, options) {
  if (typeof inlineSvgFonts === 'function') svg = await inlineSvgFonts(svg, svgFaces);
  const img = new Image();
  img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
  await img.decode();
  registerResourceImage(fileId, img, options);
  (loadImage.bytes ??= new Map()).set(fileId, new TextEncoder().encode(svg));
}

/** A face's Fontsource files: nearest weight; latin + what the SVG sets. */
async function svgFaces(family, weight, style, { codePoints = [] } = {}) {
  const [id, m] = [fontsourceId(family), await fontsourceMeta(family)];
  const w = m?.weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)) ?? weight;
  const s = m?.styles.includes(style) === false ? 'normal' : style;
  return Promise.all(['latin', ...kitSubsetsFor(String.fromCodePoint(...codePoints), m)].map(async (x) => new Uint8Array(
    await (await fetch(`${await fontsourceAt(id)}files/${id}-${x}-${w}-${s}.woff2`)).arrayBuffer())));
}

/** 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 ───────────────────────────────────────────────────────────────────────
```

## Παραλλαγές

### Υψωμένοι αριθμοί παραπομπών

Τα ιατρικά περιοδικά στοιχειοθετούν συχνά τους αριθμούς Vancouver ως εκθέτες.

```diff
-    marker: 'brackets', collapseRanges: true,
+    marker: 'superscript', collapseRanges: true,
```

### Εκτύπωση των DOI

Το BibTeX αυτής της συνταγής δεν κρατά DOI, για να μείνει μέσα στο όριο μεγέθους του pen. Κρατήστε τα στο δικό σας αρχείο και τυπώστε τα ως συνδέσμους.

```diff
-      labelWidth: mm(6.4), doi: 'hide' } },
+      labelWidth: mm(6.4), doi: 'link' } },
```

### Οι πίνακες σε μία στήλη

Ένας πίνακας 2×2 με συντομότερους τύπους χωρά σε μία στήλη: αφαιρέστε το `span: 'page'` του, όπως ο Table 4 που δεν έχει. Δείτε τη συνταγή [Δίστηλο άρθρο με αριθμημένες εξισώσεις](https://postext.dev/el/cookbook/journal-article-with-maths.md) για έναν πίνακα σε μία στήλη.

## Συνήθη λάθη

- **Τα μαθηματικά θέλουν await initMathEngine() πριν από την πρώτη κατασκευή.** Οι τύποι που τοποθετούνται πριν τρέξει η μηχανή μαθηματικών βγαίνουν γκρίζα πλαίσια κράτησης θέσης. Εισαγάγετε το initMathEngine από το https://esm.sh/postext μαζί με τα άλλα σύμβολα και περιμένετέ το με await πριν από την πρώτη κατασκευή· ένα έγγραφο με μαθηματικά που κατασκευάζεται χωρίς αυτό τυπώνει μία προειδοποίηση στην κονσόλα. Από το postext 1.5 το MathJax έρχεται μέσα στο πακέτο ως μία ενότητα που κατεβάζει το initMathEngine, οπότε η απλή εισαγωγή λειτουργεί από CDN και το ?bundle δεν χρειάζεται (έως την 1.4 κάθε σύμβολο έπρεπε να έρχεται από το https://esm.sh/postext?bundle). Εισαγάγετε από ένα μόνο URL: δύο URL φορτώνουν δύο μηχανές.
- **Τα αρχεία Fontsource καλύπτουν γράμματα, όχι σύμβολα.** Το κιτ ενσωματώνει το latin αρχείο Fontsource μιας μορφής, καθώς και το latin-ext για τα č, ł, † και το greek για τα α, χ (σε οικογένεια που το διαθέτει: η Lora και η Gelasio δεν το διαθέτουν), όταν το κείμενο τα χρησιμοποιεί, στην οθόνη και στο PDF. Σύμβολα όπως →, ≈, ✓ και ★ δεν υπάρχουν σε κανένα από αυτά τα αρχεία και λείπουν από το PDF: σχεδιάστε τα, στοιχειοθετήστε τα ως μαθηματικά ή επιλέξτε μια γραμματοσειρά της οποίας τα αρχεία τα περιέχουν.
- **Τα συγχωνευμένα κελιά θέλουν κελιά κράτησης θέσης hiddenBy: χρησιμοποιήστε το mergeCells.** Τα κελιά τοποθετούνται με βάση τη θέση τους στον πίνακα της γραμμής, οπότε ένα συγχωνευμένο κελί χρειάζεται κελιά κράτησης θέσης με σήμανση hiddenBy όπου εκτείνεται· αν τα παραλείψετε, όπως κάνει η HTML, μετατοπίζεται κάθε επόμενη στήλη. Φτιάξτε τις συγχωνεύσεις με το mergeCells. Από το postext 1.5 ένας πίνακας με ακανόνιστο πλέγμα αναφέρεται στο doc.contentWarnings ως raggedTableGrid, και το parseTSV(text, { headerRows }) σημαίνει τις γραμμές κεφαλίδας.
- **Ένα σκέτο $ ανοίγει μαθηματικά: γράψτε \$.** Το σύμβολο του δολαρίου ανοίγει ενσωματωμένα μαθηματικά, οπότε μια τιμή όπως $40 ξεκινά τύπο. Γράψτε \$40.

- Εκεί όπου ο κατάλογος του 2005 σταματά σε πέντε συγγραφείς και *et al.*, το BibTeX τελειώνει τον κατάλογο με `and others`, και το `elsevier-vancouver` τυπώνει *et al.* στη θέση του (από το postext 1.19· παλαιότερες εκδόσεις τύπωναν έναν συν-συγγραφέα με το όνομα *others*).
- Οι σελίδες διαφέρουν ανάμεσα στις εκδόσεις: το ισπανικό κείμενο είναι μακρύτερο, έτσι ο Table 4 πέφτει μία σελίδα αργότερα. Η καταγραφή δημοσιεύει τις σελίδες 1, 2, 3, 5, 6 και 7 και των δύο, ώστε οι εικόνες των σελίδων να μένουν κάτω από το όριο μεγέθους και να φαίνεται ωστόσο ο Table 4 στην καθεμία.

## Ευχαριστίες

- Συνταγή: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Κείμενο: “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 ([πηγή](https://doi.org/10.1371/journal.pmed.0020124)), CC-BY
- Γραμματοσειρές: Gelasio (OFL-1.1), Sofia Sans Semi Condensed (OFL-1.1)
- Κώδικας: MIT · Δείγμα περιεχομένου: CC-BY-4.0

## Σχετικές συνταγές

- [Αρ. 002 · Δίστηλο άρθρο με αριθμημένες εξισώσεις](https://postext.dev/el/cookbook/journal-article-with-maths.md): Ένα δίστηλο άρθρο φυσικής του οποίου τους τύπους μέσα στο κείμενο και τις επτά αριθμημένες εξισώσεις στοιχειοθετεί το MathJax και μένουν διανυσματικά στο PDF. · Επίπεδο 3 (Προχωρημένο) · Επιστημονικά άρθρα και ακαδημαϊκά κείμενα
- [Αρ. 095 · Ένα ιατρικό άρθρο σε στιλ Vancouver](https://postext.dev/el/cookbook/medical-article-vancouver.md): Αναφορά κλινικής δοκιμής σε A4 με δύο στήλες: ανυψωμένοι αριθμοί παραπομπών, αριθμημένη βιβλιογραφία Vancouver και DOI που ανοίγουν ως σύνδεσμοι στο PDF. · Επίπεδο 2 (Μεσαίο) · Επιστημονικά άρθρα και ακαδημαϊκά κείμενα
- [Αρ. 028 · Έκθεση εργαστηρίου: τύποι, δείκτες, καμπύλη ογκομέτρησης](https://postext.dev/el/cookbook/lab-report-formulas.md): Μια έκθεση χημείας τεσσάρων σελίδων σε A4 που σημειώνει τους τύπους και τις μονάδες στο κείμενο με ~ και ^ και κρατά το TeX για την αντίδραση και τις εξισώσεις. · Επίπεδο 3 (Προχωρημένο) · Εκθέσεις
