Перейти к основному содержанию
Рецепт номер 87

Рецепты · Глава 5 · Структура книги

Глава диссертации со ссылками по APA 7

Глава диссертации, где ссылки [@key, p. 33] становятся APA 7 через citeproc-js, а список литературы собирается из блока BibTeX.

На этой странице
Вывод
Canvas · PDF
Уровень
Средний
Postext
Проверено с Postext 1.65.0
Требуется ≥ 1.57.0 · postext-pdf ≥ 1.57.0
Лицензия
Обновлено 22 окт. 2026 г.
Код: MIT · Текст: CC BY 4.0
  • Образец на английском: русского издания пока нет
  • Обрезной формат 210 × 297 мм
  • 1 колонка
  • Literata 11/16
  • Public Sans
  • 3 страницы
  • Уровень
  • Postext 1.57.1
  • Свёрстано за 282 мс
  • Строк кода: 118

Коротко

Глава диссертации. Автор пишет короткий код каждого источника; Postext печатает ссылки и список литературы в конце в стиле APA.

Что получится

Вторая глава докторской диссертации по педагогике, обзор литературы: что говорят двадцать лет исследований о чтении с бумаги и с экрана. Глава набрана на странице A4 с переплётом слева, Literata с интерлиньяжем 16 пт, под бледным полем университетского синего. Источники автор держит в Zotero и вставляет выгрузку как BibTeX; в тексте каждый источник — ключ. Postext оформляет каждую ссылку по APA 7, с автором, годом и страницей, если она указана, пишет «Delgado et al. (2018)», когда имя входит во фразу, и собирает список литературы в том порядке и виде, которого требует стиль. Когда научный руководитель попросит Chicago, изменится одна строка со стилем.

Рецепт отвечает на вопросы

  • Как ссылаться на источники и собирать список литературы в APA, IEEE или другом стиле?

Короткий ответ

script.js · строки 27–39в полном коде
// Citations are written [@key, p. 33] and formatted by citeproc-js in the chosen CSL
// style; the references come from the BibTeX block at the end of the chapter. Register
// the engine once, before the first build, then the style is one setting.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = {
  style: 'apa', // 'chicago-author-date', 'ieee', 'vancouver'… change nothing else
  link: true, // each citation jumps to its entry in the PDF and on screen
  bibliography: {
    // APA asks for a half-inch hanging indent and keeps the list in the text size.
    fontSize: em(1), hangingIndent: mm(12.7), entrySpacing: pt(4),
    doi: 'link', // printed whole, as APA wants, and clickable
  },
};

Ингредиенты

Шрифты
Literata, Public Sans (SIL OFL 1.1)
Материалы
Нет: все иллюстрации рисует код

Порядок работы

#1 · Один движок, один стиль

Код приведён выше, в разделе «Короткий ответ». Postext читает ссылки, а их вид отдаёт движку ссылок, который регистрируется один раз до первой сборки; postext-citeproc оборачивает citeproc-js, движок Zotero и Mendeley, с шестнадцатью стилями CSL и файлами их локалей. [@mangen2013] даёт «(Mangen et al., 2013)», @delgado2018 без скобок ставит авторов во фразу, а [@ibanez2023, pp. 12–15] переносит диапазон страниц в скобки. Если документ испанский, те же ключи берут союзы и сокращения из испанского файла локали, потому что движок следует локали документа.

#2 · Источники берутся из блока BibTeX

Последний блок главы — :::references{format=bibtex} с вставленной внутрь выгрузкой Zotero, где диакритика записана как {\'a}. :::bibliography над ним ставит список под заголовком References; без неё Postext добавляет список в конец. Появляются только процитированные работы, в порядке APA, и каждая ссылка в тексте ведёт к своей записи.

#3 · Заголовок без номера, ссылки словами

script.js · строки 106–107в полном коде
  headingStyles: [{ id: 'references', numbered: false }],
  crossRefs: { section: t({ en: 'Section {n}', es: 'Sección {n}' }) },

Заголовок списка берёт стиль references, который оставляет его в содержании, но вне нумерации, поэтому список не становится разделом 2.4. :ref{id="sec-speed"} печатает «Section 2.2» по метке crossRefs и ведёт к заголовку; номера даёт startAt=2 в названии главы, тот же счётчик, что и у заголовков.

#4 · Начальная полоса стоит в поле

script.js · строки 43–68в полном коде
const BAND = 92; // mm from the trim's top
const opener = {
  enabled: true,
  minHeight: mm(BAND - 28 + 10), // the body starts 10 mm under the band
  slot: { elements: [
    { kind: 'box', id: 'band', style: { backgroundColor: col('tint') },
      placement: { anchor: { to: 'page', edge: 'top-left' },
        size: { width: 'fill', height: mm(BAND) } } },
    { kind: 'text', id: 'label', content: t({ en: 'Chapter', es: 'Capítulo' }),
      fontFamily: LABEL, fontSize: pt(9), fontWeight: 600, letterSpacing: pt(1.8),
      textTransform: 'uppercase',
      color: col('accent'), align: 'left',
      placement: { anchor: { to: 'container', edge: 'top-left' },
        offset: { x: mm(0), y: mm(2) } } },
    { kind: 'text', id: 'number', content: '{number}', fontFamily: TEXT, fontSize: pt(96),
      fontWeight: 300, lineHeight: 0.9, color: col('accent'), align: 'right',
      placement: { anchor: { to: 'container', edge: 'top-right' },
        offset: { x: mm(0), y: mm(-6) },
        size: { width: mm(40), height: 'auto' } } },
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: TEXT, fontSize: pt(24),
      lineHeight: 1.12, fontWeight: 600, color: col('ink'), align: 'left', overflow: 'wrap',
      placement: { anchor: { to: 'container', edge: 'top-left' },
        offset: { x: mm(0), y: mm(14) },
        size: { width: mm(108), height: 'auto' } } },
  ] },
};

Поле — прямоугольник, привязанный к обрезному краю, а текст начинается на 10 мм ниже него. Номер набран Literata Light, 96 пт, справа, где он читается как форма и оставляет названию полную ширину строки.

script.js · строки 16–21в полном коде
const palette = {
  ink: '#1b1b1f', accent: '#22406a', tint: '#e6ecf4', rule: '#b9bec8', muted: '#5d6370',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));

Рецепт целиком

Sandbox
// ═══ Postext Cookbook · Nº 087 · A thesis chapter cited in APA 7 ═══════════════════
// https://postext.dev/en/cookbook/apa-thesis-with-bibtex
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Literata, Public Sans (SIL OFL 1.1) · Needs postext ≥ 1.57.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine,
} 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 = 'apa-thesis-with-bibtex';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a thesis prints in black; the one colour is the university's
const palette = {
  ink: '#1b1b1f', accent: '#22406a', tint: '#e6ecf4', rule: '#b9bec8', muted: '#5d6370',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const TEXT = 'Literata', LABEL = 'Public Sans';
const LEAD = 16; // pt: double spacing is a typewriter habit; 1.45 reads as well and fits more

// #region answer: the citation engine, APA 7 and how its references look
// Citations are written [@key, p. 33] and formatted by citeproc-js in the chosen CSL
// style; the references come from the BibTeX block at the end of the chapter. Register
// the engine once, before the first build, then the style is one setting.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = {
  style: 'apa', // 'chicago-author-date', 'ieee', 'vancouver'… change nothing else
  link: true, // each citation jumps to its entry in the PDF and on screen
  bibliography: {
    // APA asks for a half-inch hanging indent and keeps the list in the text size.
    fontSize: em(1), hangingIndent: mm(12.7), entrySpacing: pt(4),
    doi: 'link', // printed whole, as APA wants, and clickable
  },
};
// #endregion

// #region opener: a pale band at the head of the page, the number large and light in it
const BAND = 92; // mm from the trim's top
const opener = {
  enabled: true,
  minHeight: mm(BAND - 28 + 10), // the body starts 10 mm under the band
  slot: { elements: [
    { kind: 'box', id: 'band', style: { backgroundColor: col('tint') },

Собранный script.js работает как есть: вставьте его в модульный скрипт любой страницы или откройте рецепт на CodePen. Папка рецепта на GitHub ↗ (открывается в новой вкладке)

Варианты

#Смените стиль

Та же глава в Chicago author-date убирает запятую после имени и ставит год сразу после авторов.

-  style: 'apa', // 'chicago-author-date', 'ieee', 'vancouver'… change nothing else
+  style: 'chicago-author-date',

#Сделайте список мельче текста

Многие университеты разрешают набирать список на кегль меньше и с одинарным интервалом.

-    fontSize: em(1), hangingIndent: mm(12.7), entrySpacing: pt(4),
+    fontSize: em(0.9), lineHeight: pt(13), hangingIndent: mm(12.7), entrySpacing: pt(3),

Частые ошибки

  • APA пишет заглавия статей и книг как обычное предложение, а citeproc-js печатает их так, как они заданы в данных. Zotero хранит большинство заглавий с прописных букв, поэтому поправьте их в Zotero или в BibTeX, прежде чем они попадут на страницу.

Источники и лицензии

Рецепт
Ignacio Ferro
Текст
Оригинальный текст, CC BY 4.0
Шрифты
Literata (SIL OFL 1.1) · Public Sans (SIL OFL 1.1)
SandboxPDF