En pocas palabras
El comienzo de Guerra y paz en ruso, como un libro encuadernado a la antigua. Los parlamentos en francés se traducen al pie de cada página con asteriscos que vuelven a empezar en la siguiente.
Lo que vas a componer
El capítulo I de la parte I del tomo I de Война и мир (Guerra y paz), completo, según las Obras completas (tomo 9, 1937), en una página de 130 × 200 mm, la que da el pliego ruso de 84 × 108/32. El texto va en Old Standard de 10,5 sobre 13,2 pt, 34 líneas de 100 mm. Anna Pávlovna y el príncipe Vasili hablan a medias en francés; las traducciones del propio Tolstói están al pie, con asteriscos que empiezan de nuevo en cada página. Los títulos, en Oranienbaum, escriben con letras Том первый y Часть первая. Antes va una portada en negro y rojo ladrillo, con una nota en la lengua de la edición en su vuelta.
Esta receta responde a
- ¿Cómo compongo una novela rusa: rayas de diálogo, notas numeradas por página con asteriscos y palabras que van juntas?
- ¿Cómo hago notas al pie?
- ¿Cómo escribo rayas de diálogo, años al principio de párrafo, precios y símbolos literales sin que el Markdown los malinterprete?
- ¿Cómo pongo cabeceras: el título del libro en la página izquierda, el del capítulo en la derecha y el folio por fuera?
La respuesta corta
// The language hyphenates by the Russian patterns, keeps a preposition with its word and a
// dash off the line start (bodyText.wordTies 'avoid'), holds the space after a dialogue's
// opening dash at its own width, counts the notes again on every page and indents their
// first line. The indents below are the Russian ones: 1,5 em, the first paragraph included.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
fontFamily: TEXT, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
firstLineIndent: em(1.5), indentAfterHeading: true, // the default leaves the first one flush
hyphenation: { leftMin: 2, rightMin: 2 }, maxWordSpacing: 1.6, minWordSpacing: 0.8,
wordTies: 'avoid', // the default in these languages
maxJustifyTracking: 15, // room for the ties in a 100 mm line
};
const footnotes = { // config().footnotes: *, **, ***, again from * on the next page
numberFormat: 'symbols', // locale 'ru' gives symbols: ['*'] and numbering: 'page'
fontSize: pt(8.6), lineHeight: pt(10.6),
separator: { width: 0.25, lineWidth: pt(0.4), color: col('ink') },
};
Ingredientes
- Funciones
- Los idiomas de alfabeto cirílico como idioma del documentoPalabras que no se separan a final de líneaNotas al pieSeparación silábica e idioma del documentoCorte de líneas óptimo (Knuth–Plass)Estilos de carácterFragmentos en la otra direcciónTítulos numeradosAperturas diseñadasEstilos de títuloAtributos de títuloFormato de páginaCabeceras y foliosMárgenes simétricosSangrías, alineación y separación de párrafosEstilos de párrafoMetadatos del documentoPaleta de color semánticaExportación a PDFFuentes incrustadas en el PDF
- También usa
- Color del papelCabeceras según el tipo de páginaCabeceras por secciónCapítulos sin número
- Tipografía
- Old Standard TT, Oranienbaum (SIL OFL 1.1)
- Recursos
- Ninguno: todas las imágenes se dibujan en código
Elaboración
#1 · Poner el idioma y los asteriscos
El código es la respuesta corta de arriba. locale: 'ru' separa las palabras con los patrones rusos, mantiene una preposición, un número o una raya con su palabra y cuenta las notas por página. numberFormat: 'symbols' las marca con asteriscos. La llamada se escribe donde la pone el ruso, antes del punto o la coma y después de la interrogación, y el motor no deja que el punto caiga a la línea siguiente. Una medida de 100 mm es estrecha para tantas ataduras; de ahí un poco de tracking. Cada pasaje francés va en :ltr[…]{lang=fr}, para dividirse con los patrones del francés.
#2 · Sacar la página del pliego
const [TOP, INNER, OUTER, LINES] = [22, 15, 15, 34];
const page = {
sizePreset: '84x108/32', dpi: 150, backgroundColor: col('paper'), // the sheet of GOST 5773
margins: { top: mm(TOP), bottom: mm(200 - TOP - LINES * LINE), // 130 × 200 mm
left: mm(INNER), right: mm(OUTER), mirror: true },
};
sizePreset: '84x108/32' da los 130 × 200 mm de la GOST 5773. El margen inferior se calcula a partir de 34 líneas, y mirror invierte los lados en las pares.
#3 · Espaciar una palabra, acentuar una vocal
// The edition's italics (грипп, рап) are spaced here, as Russian books set an emphasis
// before italics took over. A stress is U+0301 after its vowel: что́, сто́ите.
const characterStyles = [{ id: 'razryadka', name: 'Разрядка', letterSpacing: em(0.16) }];
Los libros rusos de la época espaciaban una palabra para destacarla. La разрядка es un estilo de carácter con letterSpacing, que aquí llevan las dos palabras que la edición pone en cursiva, грипп y рап. El acento es U+0301 detrás de la vocal, como en что́ y сто́ит.
#4 · Escribir con letras el tomo y la parte
// The Markdown has # Том, ## Часть and ### Глава; 'replace' prints the number alone. Том is
// masculine, so its ordinal asks for -masculine; Часть is feminine, the Russian default.
const level = (n, numberingTemplate, design, minHeight, extra = {}) => ({ level: n,
numberingTemplate, numberPosition: 'replace', marginTop: pt(0), marginBottom: pt(0),
breakBefore: { enabled: false },
advancedDesign: { enabled: true, minHeight: pt(minHeight * LEAD), slot: { elements: design } },
...extra });
const levels = [
level(1, 'Том {1:ordinal-masculine}', [
text('volume', '{titleText}', DISPLAY, 17, at('container', 'top', 0, 2.2 * LINE),
caps(2.4, 'red')),
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.6), color: col('red'),
placement: { ...at('container', 'top', 0, 4.5 * LINE), size: { width: mm(18) } } },
], 5, { breakBefore: { enabled: true, parity: 'odd' } }),
level(2, 'Часть {2:ordinal}', [text('part', '{titleText}', DISPLAY, 11.5,
at('container', 'top', 0, 0.4 * LINE), caps(1.6))], 2),
level(3, '{3:upper-roman}', [text('chapter', '{titleText}', DISPLAY, 13,
at('container', 'top', 0, 0.9 * LINE), {})], 3),
];
{1:ordinal-masculine} y {2:ordinal} escriben los contadores con palabras en la lengua del documento, y numberPosition: 'replace' los imprime en lugar del título. El Markdown dice # Том y ## Часть, y nadie tiene que reescribir un número.
#5 · Las cabeceras
const head = (id, content, parity, edge, x, extra = {}) => ({ kind: 'text', id, content, parity,
pages: 'body', fontFamily: TEXT, fontSize: pt(9), color: col('ink'),
placement: at('page', edge, x, 13), ...extra });
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER),
head('verso-author', '{author}', 'even', 'top', 0, { italic: true }),
head('recto-title', '{title}. {chapterTitle}', 'odd', 'top', 0, { italic: true }),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER),
{ kind: 'rule', id: 'under', direction: 'horizontal', thickness: pt(0.4), color: col('ink'),
pages: 'body', placement: { ...at('page', 'top', 0, 18), size: { width: mm(100) } } },
] };
const footer = { elements: [{ ...head('drop', '{pageNumber}', 'all', 'bottom', 0),
pages: 'opener', placement: at('page', 'bottom', 0, -11) }] };
El autor va sobre las pares y el título con su tomo sobre las impares, en cursiva y con un filete fino debajo. pages: 'body' deja limpio el arranque, que lleva el folio al pie.
#6 · Una portada a dos tintas
const front = (id, elements, furniture = [], extra = {}) => ({ id, numbered: false,
runningChapter: false, breakBefore: { enabled: true, parity: 'any' }, numberPosition: 'before',
header: { elements: furniture }, footer: { elements: [] },
advancedDesign: { enabled: true, slot: { elements }, ...extra } });
const frame = (id, inset, width) => ({ kind: 'box', id,
style: { borderColor: col('red'), borderWidth: pt(width) },
placement: { ...at('page', 'top-left', inset, inset),
size: { width: mm(130 - 2 * inset), height: mm(200 - 2 * inset) } } });
const headingStyles = [
front('title-page', [
text('author', '{attr.first}', DISPLAY, 17, at('page', 'top', 0, 30), caps(1.6)),
text('title', '{titleText}', DISPLAY, 40, { ...at('page', 'top', 0, 66),
size: { width: mm(98) } }, { ...caps(0.6, 'red'), lineHeight: 1.1 }),
text('subtitle', '{subtitle}', TEXT, 11, at('page', 'top', 0, 92), { italic: true }),
text('imprint', '{attr.imprint}', DISPLAY, 10, at('page', 'bottom', 0, -29), caps(1.6)),
text('year', '{attr.year}', DISPLAY, 10, at('page', 'bottom', 0, -23)),
], [frame('outer', 10, 2.2), frame('inner', 12.2, 0.5)]), // the section's header: whole page
// The note sits low on the verso of the title page, under its label.
front('note-page', [text('label', '{titleText}', DISPLAY, 10,
at('container', 'top', 0, 17 * LINE), caps(1.2, 'red'))], [], { minHeight: pt(19 * LEAD) }),
];
El marco está en la cabecera de la sección, donde puede ocupar la página entera; los textos salen del título y de sus atributos.
La receta completa
// ═══ Postext Cookbook · Nº 205 · A Russian novel with its notes counted by page ═══════
// https://postext.dev/en/cookbook/russian-novel-notes-by-page
// Code: MIT · Text: L. Tolstoy, Война и мир, I, I, I, PSS vol. 9, 1937 (PD, ru.wikisource)
// Fonts: Old Standard TT, Oranienbaum (SIL OFL 1.1) · Needs postext ≥ 1.100.0
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'es'; // @lang: the language of the note on the text ('en' | 'es' | 'ru')
const RECIPE = 'russian-novel-notes-by-page';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// Black on a warm paper and the brick red of a title page printed in two inks, as the
// Leningrad presses of the thirties set their classics.
const palette = {
ink: '#1e1a17', // text, the running heads, the folios
red: '#a3301f', // the title, the frame, the volume
muted: '#675e55', // the note on the text, the colophon
paper: '#faf5ea', // a cream book paper
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'red (defaults)', value: { hex: palette.red, model: 'hex' } },
];
const [TEXT, DISPLAY] = ['Old Standard TT', 'Oranienbaum']; // обыкновенная; a display antiqua
const [BODY, LEAD] = [10.5, 13.2]; // pt
const LINE = (LEAD * 25.4) / 72; // mm: one line, 4.66
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, fontFamily, size, placement, extra = {}) => ({ kind: 'text', id,
content, fontFamily, fontSize: pt(size), color: col('ink'), align: 'center',
overflow: 'wrap', placement, ...extra });
const caps = (tracking, color = 'ink') => ({ textTransform: 'uppercase',
letterSpacing: pt(tracking), color: col(color) });
// #region page: 84 × 108/32, 130 × 200 mm trimmed; 34 lines of 13.2 pt, 100 mm wide
const [TOP, INNER, OUTER, LINES] = [22, 15, 15, 34];
const page = {
sizePreset: '84x108/32', dpi: 150, backgroundColor: col('paper'), // the sheet of GOST 5773
margins: { top: mm(TOP), bottom: mm(200 - TOP - LINES * LINE), // 130 × 200 mm
left: mm(INNER), right: mm(OUTER), mirror: true },
};
// #endregion
// #region answer: what locale 'ru' brings, and the notes set with asterisks
// The language hyphenates by the Russian patterns, keeps a preposition with its word and a
// dash off the line start (bodyText.wordTies 'avoid'), holds the space after a dialogue's
// opening dash at its own width, counts the notes again on every page and indents their
// first line. The indents below are the Russian ones: 1,5 em, the first paragraph included.
El script.js compuesto funciona tal cual: pégalo como script de módulo en cualquier página o abre la receta en CodePen. Carpeta de la receta en GitHub ↗ (se abre en una nueva pestaña)
Errores frecuentes
- Más de tres o cuatro asteriscos por página frenan al lector, y la página 9 llega a cinco. Junta en una sola nota las traducciones de un mismo parlamento, como hace esta receta, o usa cifras con
numberFormat: 'decimal'. - Una llamada escrita después del punto se queda después del punto. El orden lo pone el Markdown.
Créditos
- Receta
- Ignacio Ferro
- Texto
- Война и мир, tomo I, parte I, capítulo I, completo, según las Obras completas (PSS, t. 9, 1937) en la transcripción de ru.wikisource, con las erratas de la transcripción corregidas, las traducciones de Tolstói colocadas como en las ediciones actuales y la llamada de nota antes del punto · Leo Tolstoy · dominio público
- La nota sobre el texto y el colofón · Postext Cookbook · original
- Fuentes
- Old Standard TT (SIL OFL 1.1) · Oranienbaum (SIL OFL 1.1)
- Código
- MIT, como Postext
Editar este texto ↗ (se abre en una nueva pestaña)Carpeta de la receta en GitHub ↗ (se abre en una nueva pestaña)


